git - reverse patching stashed changes preserving new changes - why reverse patch fails -
i've come across answer on so. provides recipe on how reverse changes made applied stash preserve other changes files. i've tried going through script provided example patch failed:
checking patch messages... error: while searching for: hello, world hello again error: patch failed: messages:1 i've noticed answer of 2009, approach valid today? i'm curios afaik when git applies patch searches context lines before , after change, in example in question context after change won't match, how's patch supposed applied?
a stash commit other , therefore can reverted.
let's assume did
git stash and later
git stash pop which restore changes in working directory. keep on working , modify other files. commit changes new commit.
now if want revert changes came stash can if know stash's commit id. since did stash pop gone , git not make reflog entry.
but might recover searching dangling commits. e.g.
git fsck --no-reflog | awk '/dangling commit/ {print $3}' but easier if use gitk
gitk --all $( git fsck --no-reflog | awk '/dangling commit/ {print $3}' ) look merge commit. git stores stashs merge commits, because saves actual staged changes in commit named index on trunk: ... , actual working dir changes merge commit of staged changes , head stash depends on.
in git stash commit this:
head | v a---b---d <-- stash commit \ / c <-- staged changes commit if found stash commit can revert using it's id. according example above a
git revert -m 1 d
Comments
Post a Comment