On Mon, Feb 15, 2010 at 10:09:02AM +0530, Pavan Kumar Sunkara wrote: > When you clone a big git repository and would like to read and > understand the source code, you need to checkout and read every commit > right from the first commit. As per my knowledge, there is no command > (even with flags) to checkout the first commit of the repository. > > If there is some command, please put it in user's manual In most repositories, you can do this: git checkout `git rev-list --reverse HEAD | head -n 1` but... > I know that every git commit is a vertice in a DAG which has it's edge > pointed to it's parent. So, walking from the latest commits to old > commits is easy but the reverse is not. > I would like to know if there is any problem if we make the walking > bidirectional. What i mean is, when a new commit is created, create an > edge not only from it to it's parent but also from it's parent to it. > Also, have something for the first commit of the repo which can be > referred as INIT (similiar to HEAD) It is not as simple as that, for two reasons. For walking backwards, you can take multiple paths from merge commits (which have multiple parents). So there may actually be several "first commits" if unrelated lines of development were merged together. For example, in git.git: $ git log --format='%h %p' | grep ' $' 16d6b8a cb07fc2 161332a 1db95b0 2744b23 e83c516 There are six root commits. You can see what they are by piping the above into "tr -d ' ' | git log --no-walk --stdin". For your "--next" suggestion, it is even worse. There may be an infinite number of commits that point to a given commit as the parent. So there is no such thing as "what came next from X". You can only ask "leading up to some commit Y which is a descendant of X, what was the commit that came after X". But while there are a finite number of answers, there is not necessarily just one. If two branches diverged at X and then remerged before Y, they are both equally "next". -Peff -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html