Why don't Git refs have a file extension

I had recently stumbled upon a common problem in Git when creating branch groups:

I had a branch called “tim“.
I wanted to make a folder/group called “tim“, with the “tim” branch inside it, resulting in the branch path being “tim/tim“.

When I tried to do this, Git really hated me because the folder “tim” and the branch ref “tim” were the exact same thing according to Git.

My question, is if anyone knows why does a branch ref not have an extension of some sort to get around this issue? Say .gitbranch or whatever?
Obviously it’d be a little more work to append on .gitbranch whenever accessing the file, but barely anything compared to the work the user has to do to get around this issue, especially when you’re in a development team. (Anyone who had previously cloned the repo had to then manually go into their refs folder and remove any trace of branches named “tim“, otherwise they couldn’t fetch!)

If this actually a legitimate issue, I will raise it with the appropriate channels, but I wanted to check if anyone could possibly know why they could have possibly done this purposefully?

Thanks all,

  • Git : fatal: Ambiguous object name: 'origin/release_2.6'
  • Reference Git branch start commit
  • Why does git update-ref accepts non /refs references?
  • How should I use SQL Server Compact Edition in a SharpDevelop project on multiple computers using Git?
  • Best way to reference an external library in multiple projects in a Visual Studio solution
  • How do you reclaim disk space after adding an alternate in git?
  • Github and Nuget packages
  • How to “dereference” a string to a git sha1 hash?
  • 2 Solutions collect form web for “Why don't Git refs have a file extension”

    I don’t think there is any particular rationale either way. In unix one does not normally use file extensions, so there were none. That meant you can’t have a foo and foo/anything at the same time. That was documented and is now cast in stone and won’t change, though the remote references are usually stored in the packed format all in one file these days.


    • git fetch should be smart enough to prune the old branch before creating the new one if given the -p (--prune) option is given. If it does not, you should definitely bring it up on git mailing list.
    • I only see a way to default prune in gui, but not in the fetch config for the remote. It would make sense to ask about that as well.

    Git can have difficulties when you try to convert a file name tim (which stores the branch head) to a directory name tim/ (when you have slashes) because of the naming freedoms for references (see git-check-ref-format).

    Git Baby is a git and github fan, let's start git clone.