theredwagoneer
theredwagoneer

Reputation: 3

In Git, how can two hashes point to one commit?

I have some scripts that query our host (Gitlab) for all of a project's tags and the commit hashes that the tags point to. Then it does some more work with those hashes.

This generally works, but I have one commit where I get a different hash than what is displayed with a git log on that commit.

The thing is, it's not exactly wrong. The hash that is returned does let me checkout the correct commit:

>>git checkout 6a923
HEAD is now at ae67e044

and

>>git log -1 6a923
commit ae67e044359c86781fd7c1b74016f858f00584f8 (HEAD, tag: <correct tag>)

but it obviously doesn't serve when I want to do things like compare hashes later on.

I thought hashes were unique. This seems to be some kind of alias hash. What is going on here?

Additional Info:

>>git cat-file -p 6a923
object ae67e044359c86781fd7c1b74016f858f00584f8
type commit
tag <correct tag>
tagger <correct tagger> 1558448485 -0400

Upvotes: 0

Views: 523

Answers (1)

eftshift0
eftshift0

Reputation: 30297

6a923 is just an annotated tag that points to revision ae67e04435. https://git-scm.com/book/en/v2/Git-Basics-Tagging

Upvotes: 6

Related Questions