Today, we’ll show you how to use git stash to save changes temporarily. You may need to save your work momentarily at times. So you may accomplish it with the git stash command.
Different way to save changes using git stash
- Check list of stashed changes
- Save changes
- Save changes including untracked files
- Save changes with description
- Re-apply saved changes
- Re-apply saved changes and remove it from stash list
1. Check list of stashed changes
You can check stashed changes anytime by running the following command in the terminal.
git stash list
2. Save changes
To save changes temporarily, you have to run the following command.
Above command will stash only modified files. It’ll not include untracked files.
3. Save changes including untracked files
To save changes including untracked files, run stash command along with
--include-untracked. Check the following command.
git stash --include-untracked
git stash -u
4. Save changes with description
It’s good practice to save changes with a small description. So that changes could be easy to identify. Use the command
git stash save "message" to stashes with description.
git stash save "your message will come here..."
5. Re-apply saved changes
To re-apply stashed changes, run the following command.
git stash apply
6. Re-apply saved changes and remove it from stash list
If you want to re-apply the stashed changes and also want to remove it from the stash list then you can use
git stash pop
That’s it for today.
Thank you for reading. Happy Coding..!!