3 ms·
I 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, thou
by ekzy 10y ago
I 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.