Git: Reverse a stash apply
Sometimes I want to undo a git stash apply.
git stash show -p | git apply --reverse
That combines:
Show the changes recorded in the stash as a diff between the stashed state and its original parent. When no <stash> is given, shows the latest one. By default, the command shows
the diffstat, but it will accept any format known to git diff (e.g., git stash show -p stash@{1} to view the second most recent stash in patch form).
(Extracted from git-stash man page)
and
-R, --reverse
Apply the patch in reverse.
(Extracted from git-apply man page)
Written by Daniel Schmidt
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Git
Authors
khasinski
591.1K
dmichaelavila
500.4K
Related Tags
#git
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#