git stash

Save file-changes without committing anything.

Change a file:

1file=README.md
2fortune >> ${file}
3git diff
4git stash save

List which stashes you have:

1git stash list
2
3    stash@{1}: WIP on master: c21f102 init git

Make a new file, then stash it:

1otherfile=file.log
2fortune > ${otherfile}
3git add ${otherfile}
4stashname=logfile
5git stash save ${stashname}

Now you can see two stashed changes, and the most recent has a name:

1git stash list
2
3    stash@{0}: On master: logfile
4    stash@{1}: WIP on master: c21f102 init git

You can delete a stash by referring to its index number, or name (if it has one).

1choice=1
2git stash drop ${choice}
3
4choice=${stashname}
5git stash drop ${choice}

Or just run git stash drop to remove the most recent (labelled {0}).

Return stashed changes with an index number (or the most recent).

1git stash pop ${choice}

Delete all stashes:

1git stash clear