When should I use git stash save
instead of git stash push
and vice-versa?
When you 'git stash', it will get saved/pushed in a 'STACK' type temporary location (let's call that stash-list) so that you can pop/apply them later. The latest stash will be stored in refs/stash . And the subsequent pushes will be available in the reflog of this reference.
git stash temporarily shelves (or stashes) changes you've made to your working copy so you can work on something else, and then come back and re-apply them later on.
Git stash saves the uncommitted changes locally, allowing you to make changes, switch branches, and perform other Git operations. You can then reapply the stashed changes when you need them. A stash is locally scoped and is not pushed to the remote by git push .
git stash apply vs pop : They are almost similar except the fact that git stash pop throws away the (topmost, by default) stash when applying it, whereas git stash apply leaves it within the stash list for possible later use (or you'll then git stash drop it).
git stash save
accepts a single non-option argument — the stash message.
git stash push
accepts the message with option -m
and accepts a list of files to stash as arguments.
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