Schwern Schwern - 2 months ago 7
Git Question

How do I find the next commit in git?

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?

Answer

To list all the commits, starting from the current one, and then its child, and so on - basically standard git log, but going the other way in time, use something like

git log --reverse --ancestry-path 894e8b4e93d8f3^..master

where 894e8b4e93d8f3 is the first commit you want to show.