view raw
Eye of Hell Eye of Hell - 6 months ago 48
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


git clone && 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?


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.