Eye of Hell Eye of Hell - 29 days ago 17
Git Question

git branch --contains errors "no such commit", while github shows that commit exists

I want to check what branches contains this github commit.

So i performed following terminal spells on one of my boxes running git version

1.9.5.msysgit.1
:

git clone git@github.com:npm/npm.git && cd npm
git branch -a --contains 5ff786ae103161465d84ecdfdc5b0cfd8839eac8


Surprisingly, I'm getting error that such commit does not exist at all:

error: no such commit 5ff786ae103161465d84ecdfdc5b0cfd8839eac8



How this can happen if github shows this commit?

Answer

As we figured out this is due to the fact that github shows you in a weired way an orphaned commit. Actually they performed some history rewriting and the commit got kicked out of the official history. But it is still reachable, if you perform a

$ git log --all -grep="Sort actions by dependency order"

you still find the correct commit.