1

I want to see how a large app was built from scratch by following along from its first commit. I get the first commit by using git log and do a git checkout commitId. From this point on I want to do git checkout "some magic" where some magic is basically more git commands with pipe/grep/tail etc that will give me the next commit id. Is this possible or do I have to git log and keep sorted list of all the commit id's and do copy paste for each checkout in sequence ? Thanks

Gullu
  • 3,477
  • 7
  • 43
  • 70
  • 3
    You can do anything with programming. :) But Git itself does not know what the "next" commit is; the concept has no meaning for Git. A commit points only "backward" (to its parent(s)). So you will have to walk the history first. – matt Sep 10 '21 at 18:54
  • 2
    There's not always one single "next" commit: what about when a branching occurs? – Gaël J Sep 10 '21 at 18:55
  • 1
    Maybe the OP's question can be rephrased as: "easily find the next commit between HEAD and a given branch (e.g., master, or sth specified in CLI)" – ErikMD Sep 10 '21 at 18:56
  • 1
    But indeed, there is an ambiguity if there is branching, and merges in-between. However, we might want to further rephrase this as "easily find the next commit between HEAD and a given branch (e.g., master, or sth specified in CLI), stepping by default to the first parent" (see e.g. [`git log --first-parent`](https://git-scm.com/docs/git-log#Documentation/git-log.txt---first-parent) or `gitk --first-parent`) – ErikMD Sep 10 '21 at 18:57
  • Not sure why this is marked as duplicate... The other question doesn't talk about how to get git to actually *checkout* the next commit. (Yes, you can do it with programming, but the point is to find the standard way to do it). – personal_cloud Jan 01 '23 at 02:15

0 Answers0