I have a completely linear git history (to make things simple), such that
git log --oneline --graph --all
shows
* eff3139 (branch_2) foo
* f217e05 bar
* 8d1c27b baz
* c10bb66 (HEAD -> master, origin/master, origin/HEAD) qux
* dd2952b quz
* 321dedc zot
* b00284b blarg
with head sitting on master at c10bb66, it's easy for me to check out dd2952b with git checkout @~
or 321dedc using the same but with @~2. However, how do I easily checkout 8d1c27b, or f217e05, or other children of the current commit?
git checkout @~-1
(my only idea) unfortunately leads to the error error: pathspec '@~-1' did not match any file(s) known to git
I suspect there's no way to do this in git, which is a shame.
I suspect there is no way to do this in git, unless there has been some recent addition. Although the question asked isn't exactly the same, the answers to What is the opposite of `git diff HEAD^`?, Referencing the child of a commit in Git, and How do I find the next commit in Git? (child/children of ref) seem to suggest that there is no way to do this in git.
(Many of the answers erroneously suggest that this is impossible as a matter of principle — but it's not impossible, as git log --oneline --graph --all
shows; git just won't let you do it.)