jww
jww

Reputation: 102245

Why does git think HEAD is the first commit from 17 years ago?

I'm trying to gather up the list of commits in the range [NOW, THEN], where NOW is HEAD and [THEN] is 8af39377, and its about 120 commits ago.

When I run:

>  git log 8af39377289feba1876b3252b6d23 HEAD --oneline | cut -d " " -f 1 > commits.txt

and then look at commits.txt, its 2300 lines long and it shows the top entry as 8af39377 (the THEN) and the bottom entry as a3b6ece (the first commit from 2002).

Why does Git think HEAD is the first commit to the repository?

Upvotes: 1

Views: 411

Answers (2)

jthill
jthill

Reputation: 60275

git log 8af39377289feba1876b3252b6d23 HEAD --oneline

That says "give me the entire history of those two commits, sorted in date order constrained by ancestry".

You want

the list of commits in the range [NOW, THEN], where NOW is HEAD and [THEN] is 8af39377, and its about 120 commits ago

but your log output contradicts you on which is which: git log shows its output most-recent first, constrained by ancestry, and

it shows the top entry as 8af39377.

so you're wrong about your commit order. If you hadn't silenced the default output it would have shown you the commit dates explicitly as well, so you'd see whether it's a date or ancestry issue.

Regardless which it is,

git log --oneline HEAD..8af39377

will show you the list.

It might be worth adding --graph --decorate.

Upvotes: 1

jbu
jbu

Reputation: 16131

Your syntax is wrong. If you want the range between 8af39 and HEAD then you need 8af39..HEAD

As for WHY it's showing 17 years ago, if you just specify a single revision, it will find all the commits REACHABLE by that commit. Since all commits have backwards pointers all the way to the root, you're finding the root commit.

Revision Specification See the section on specifying a range.

Upvotes: 3

Related Questions