git stash
to put it aside.Additionally, I would like to backup that stash content on a shared drive. Just for safety. What is an elegant solution to archive the stash content on file?
Retrieve Stashed Changes To retrieve changes out of the stash and apply them to the current branch you're on, you have two options: git stash apply STASH-NAME applies the changes and leaves a copy in the stash. git stash pop STASH-NAME applies the changes and removes the files from the stash.
All are stored in . git/refs/stash . git stash saves stashes indefinitely, and all of them are listed by git stash list . Please note that dropping or clearing the stash will remove it from the stash list, but you might still have unpruned nodes with the right data lying around.
You can create stash as patch file from one machine,then can share that patch file to another machines. The “stash@{0}” is the ref of the stash.It will create patch file with latest stash. If you want different one use command $ git stash list to see your list of stashes and select which one you want to patch.
You can get the diff by running show command:
git stash show -p > stash.diff
This is the diff file which you can use as a backup.
Later you can apply the diff to the existing repository:
git apply stash.diff # and potentially stash again: git stash
I don't want to commit it
Actually, git stash
operates by making two commits (sometimes) three, so if you stashed your work, you committed perhaps without even knowing it. But there is nothing wrong most of the time with making a temporary commit. Just add your current work, and then make a temporary commit via:
git commit -m 'WIP'
Then, you can push your branch out to the repository, and that should serve as a backup. When you return to finish the work, you can amend that temporary commit via:
git commit --amend
Feel free to change the message to something more meaningful, but in any case the WIP
message can serve as a reminder.
If the branch you are working on could be shared by others, then you could push your branch with the temporary commit to a different location as a backup, e.g.
git push origin local_branch:some_other_location
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