Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does GIT STASH persist even after a computer shutdown? [duplicate]

Tags:

git

linux

github

I've read about using git stash to save work on a particular branch when needing to work on another, but my question is do those saved changes only stay saved for a particular session, or would they remain saved until they are destroyed (even after rebooting a computer) and be recovered later?

The root of the problem is: I have a computer with me at work which I develop on, and which cannot access the internet. Thus, I cannot push changes to git remotely. I would need to save them temporarily, shut down my computer, and push them when I get home. Is this possible?

like image 465
Jotunblood Avatar asked Apr 06 '15 18:04

Jotunblood


People also ask

What happens to Your Stash when you push it to Git?

Note that the stash is local to your Git repository; stashes are not transferred to the server when you push. Re-applying your stashed changes. You can reapply previously stashed changes with git stash pop: Popping your stash removes the changes from your stash and reapplies them to your working copy.

How to remove all stashed changes in Git?

The solution is to fix the merge issues first and then stage the fixed files. You can use git stash drop <stash_id> to delete any of the stashed changes. For example, since I have already created my create_groups.sh script so I will drop the duplicate stash change:

What is Git stash and clean?

Stashing and Cleaning. The answer to this issue is the git stash command. Stashing takes the dirty state of your working directory — that is, your modified tracked files and staged changes — and saves it on a stack of unfinished changes that you can reapply at any time (even on a different branch).

Is Git stash save being deprecated?

As of late October 2017, there has been extensive discussion on the Git mailing list, wherein the command git stash save is being deprecated in favour of the existing alternative git stash push . The main reason for this is that git stash push introduces the option of stashing selected pathspecs, something git stash save does not support.


1 Answers

Yes, the stash is persisted to disk, and thus survives reboot.

git doesn't retain any content in-memory (or in an alternate fragile state, such as unlinked files) between command invocations; doing so would require an out-of-process daemon or other component that isn't presently included -- thus, substantial extra complexity for no significant gain.


That said, given the workflow you've described, I don't see why you'd need to use the stash day-to-day when working disconnected. Just commit your changes locally, and push (without using --force) when connected. Depending on your team's workflow, it may be appropriate to rebase onto the current state of the branch, or to merge down new changes before pushing. Ask your team's dev lead which approach they prefer, if explicit workflow documentation local to your company or project isn't available.

like image 100
Charles Duffy Avatar answered Oct 16 '22 10:10

Charles Duffy