Useful git stash commands - Anjum219/Git-basics GitHub Wiki

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.

git stash

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

git stash save "save message"

Now, time to restore the changes. Checkout to the relevant branch and write

git stash apply

It will apply the latest stash in the current branch. If you need to apply a different stash, you camn do so using

git stash apply <stash_id>

stash_id can be known by writing the command-

git stash list

It will show the list of all stashes with their id. The id is generally with the format stash@{1}

⚠️ **GitHub.com Fallback** ⚠️