Header

git stash

Discarding recent uncommitted changes in your current copy of the repository

If you have some changes that you wish to discard but save for later, for example if you're changing to a different branch and you've not finished your work, you can run this command:

Saving for later

$ git stash
Saved working directory and index state WIP on master: 0dda643 Add edam

Any uncommitted changes will now be undone, and you'll be back to the last committed version.

Restoring your work

If you've gone ahead and completed work else, but you then want to resume what you were doing originally, you can type this command:

$ git stash apply

This will automatically restore any uncommitted work from the last time you ran git stash. If you've done this multiple times, you can run the following to view a list of previous "stashes":

$ git stash list

stash@{0}: WIP on master: 0dda643 Add edam
stash@{1}: WIP on my-new-branch: 56aedbe remove old folder

You can then use git stash apply stash@{1}, specifying the name of the previous stash. to restore your uncommitted work from there.

Tree

Proudly powered by Katapult. Running on 100% renewable energy.