• Post category:Git
  • Reading time:4 mins read

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

  1. Check list of stashed changes
  2. Save changes
  3. Save changes including untracked files
  4. Save changes with description
  5. Re-apply saved changes
  6. 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.

git stash

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

OR

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 pop.

git stash pop

That’s it for today.
Thank you for reading. Happy Coding..!!

Leave a Reply