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?
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.
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:
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).
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With