Git

git stash

Showed to me by Xavier during my internship at NVIDIA. Actually quite powerful once you get to understand how to use it.

Resources

git stash show <stash_id>

To see the actual file diffs, add the -p flag

git stash show -p <stash_id>

Viewing your stashes

git stash list

Storing Stashes

Xavier uses this command

git stash push -m "tag_name"

From the tutorial, there is

git stash save "add style to website"

Both are very similar. The difference between save and push:

  • git stash save accepts a single non-option argument — the stash message
  • git stash push accepts the message with option -m and accepts a list of files to stash as arguments

Applying Stashes

Afterwards, when it comes to using your stashes, you can do

git stash apply

Difference with git stash pop?

I used to use git stash pop. The difference is that apply keeps it in the stash history, whereas pop removes it.

If you have multiple stashes, you can do this

git stash apply stash@{1} 

Checking out specific files:

git checkout stash@{1} -- /path/to/file1 /path/to/file2 ...