ref^
refers to the commit before ref
, what about getting the commit after ref
?
For example, if I git checkout 12345
how do I check out the next commit?
Thanks.
PS Yes, git's a DAG node pointer struct tree whatever. How do I find the commit after this one?
There is no unique "next commit". Because history in Git is a DAG, and not a line, many commits can have a common parent (branches), and commits can have more than one parent (merges).
If you have a particular branch in mind, you can look at its log and see what commit lists the present one as its parent.
If the child commits are all on some branch, you can use
gitk --all commit^..
, where "commit" is something identifying the commit. For example, if the commit's abbreviated SHA-1 is c6661c5, then typegitk --all c6661c5^..
You will probably need to enter the full SHA-1 into gitk's "SHA1 ID:" cell. You will need the full SHA-1, which for this example can be obtained via
git rev-parse c6661c5
Alternatively,
git rev-list --all --children | grep '^c6661c5883bb53d400ce160a5897610ecedbdc9d'
will produce a line containing all the children of this commit, presumably whether or not there is a branch involved.