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“.
- How to “dereference” a string to a git sha1 hash?
- Github and Nuget packages
- How do you reclaim disk space after adding an alternate in git?
- git remote branch multiple elements reference
- Best way to reference an external library in multiple projects in a Visual Studio solution
- How should I use SQL Server Compact Edition in a SharpDevelop project on multiple computers using Git?
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?
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/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 fetchshould be smart enough to prune the old branch before creating the new one if given the
--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