A git stash cheat sheet
A summary of usages of git stash commands:
1. List current stashes
[code language="xml"]
> git stash list
[/code]
2. Deleting stashes
Delete all stashes:
[code language="xml"]
> git stash clear
[/code]
Delete specific stash (stash id in quotes on PowerShell):
[code language="xml"]
> git stash drop <stashId>
[/code]
3. Save stash(es), annotated with a message
[code language="xml"]
> git stash save my message...
[/code]
4. Apply the most recent stash
[code language="xml"]
> git stash apply
[/code]
5. Apply a specific stash
[code language="xml"]
> git stash apply --index 2
[/code]
or use stash{0}:
[code language="xml"]
> git stash apply stash@{1}
[/code]
If you are using a Powershell-based command line, it won't like the curly braces, so enclose it in quotes
and it should work:
[code language="xml"]
> git stash apply "stash@{1}"
[/code]
6. Remove all stashes
[code language="xml"]
> git stash clear
[/code]
7. View stash changes / diffs
To view a brief summary:
[code language="xml"]
> git stash show
[/code]
To view the full diff:
[code language="xml"]
> git stash show -p
[/code]
To view the full diff on a specific stash (enclose stash@.. in quotes if Powershell command line):
[code language="xml"]
git stash show -p stash@{2}
[/code]
Comments
Post a Comment