In this situation:
v HEAD
o--o--o--x--o--o (foo)
/
o--o--o--o--o--o--o (master)
If I want to move one step backward I type:
$ git checkout HEAD~1
v HEAD
o--o--o--x--o--o (foo)
/
o--o--o--o--o--o--o (master)
If I want to move a step forward I came with this ridiculous command:
$ git log --pretty=oneline --all | \
grep -B1 `git rev-parse HEAD` | \
head -n1 | egrep -o '[a-f0-9]{20,}' | xargs git checkout
v HEAD
o--o--o--x--o--o (foo)
/
o--o--o--o--o--o--o (master)
Can I do better such as git checkout HEAD+1
?
My current implementation in my ~/.gitconfig
is:
[alias]
# Move forward/Backward
fw = "!git log --pretty=oneline --all | grep -B1 `git rev-parse HEAD` | head -n1 | egrep -o '[a-f0-9]{20,}' | xargs git checkout"
bw = "!git checkout HEAD~1"