You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hasnat Anjum Haz edited this page Jun 29, 2021
·
4 revisions
git stash is very useful when you are working in a branch and you need to switch to a different branch immediately. You are not ready to stage or commit your code yet. Here comes the helping hand of git stash.
gitstash
That's it. All your changes are stashed. Now you are free to roam around in any branch you like. You can also stash the changes with a message
gitstashsave"savemessage"
Now, time to restore the changes. Checkout to the relevant branch and write
gitstashapply
It will apply the latest stash in the current branch. If you need to apply a different stash, you camn do so using
gitstashapply<stash_id>
stash_id can be known by writing the command-
gitstashlist
It will show the list of all stashes with their id. The id is generally with the format stash@{1}