Skip to content
Discussion options

You must be logged in to vote

While the Git internal reasons for why this happens are perfectly logical, it is a gotcha moment when it happens, as it is most likely to happen when working with a remote and the user unexpectedly runs into some internal Git mechanics.

Git stores the commit pointing to the tip of the branch in .git/refs. There may be remotes configured, and they end up under remotes, there's heads which contains references to the HEAD of each branch locally. The examples use refs/head for simplicity. The principles apply to refs/remotes as well.

git checkout -b foo creates a file named foo under .git/refs/heads with a commit hash as content.

$ git checkout -b foo
Switched to a new branch 'foo'

$ ls -l -…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by varl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #100 on December 14, 2020 07:54.