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“.

  • Git: get the list of branches into which current branch was ever merged
  • How can I label my current git branch as ok then continue
  • GIT: remove remote branches with no local tracking branch
  • Is there a 3 way merger tool that “understands” common refactoring?
  • How to recover a merge commit after a rebase on the same commit?
  • git: how do I merge between branches while keeping some changesets exclusive to one branch?
  • 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,
    Tim

  • How to Diff between local uncommitted changes and origin
  • Git add . failing on subdirectory that has a .git folder, even though being ignored
  • Move the most recent commit(s) to a new branch with Git
  • .gitignore not ignoring filenames with spaces in them on `git status`
  • Unable to connect to GitHub within Eclipse due to SunCertPathBuilderException: certificate not found
  • how to integrate git on mplab.x
  • 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.

    However:

    • 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.