3 ms·
It should automatically skip reflogs created by undo itself, so git undo; git undo be equivalent to git undo 2, and for undoing undo there should be seperate gi
by garaetjjte 10y ago
It should automatically skip reflogs created by undo itself, so git undo; git undo be equivalent to git undo 2, and for undoing undo there should be seperate git redo.
- ekzy 10y agoI agree with that. So you could undo step by step without thinking about the number to put next to your undo command. It seems a bit trickier to implement, though
- garaetjjte 10y agoOnly a bit of awk magic: ~/git-undo.awk: BEGIN { jmp = 0 } { match($2, "{([0-9]+)}", c); if (c[1] == jmp) { jmp++; if ($3 == "reset:") { match($6, "{([0-9]+)}", x); jmp += x[1]; } else i--; if (i == 0) { print jmp; exit; } } } git config --global alias.undo '!f() { git reset --hard $(git rev-parse --abbrev-ref HEAD)@{$(git reflog | awk -v i=${1-1} -f ~/git-undo.awk)}; }; f' Redo is also possible, but i don't have time now to do it.