I have always assumed that the .git/branches
directory is for legacy purposes and that git used to use that directory, but now uses the .git/refs
directory instead. Is this true? If not, then what is the purpose of that directory since I have never seen it used or referenced.
EDIT
I'm using git version 1.7.3.4.
A folder is a feature of the filesystem. A branch is a feature of version control systems, which means that Git tracks at which point in the version history you created it.
The git branch command allows you to create, list, rename and delete branches. Many operations on branches are applied by git checkout and git merge command. So, the git branch is tightly integrated with the git checkout and git merge commands.
Gitflow. Although Gitflow doesn't mention branch folders, many devs use "Feature branches", "Hotfix branches" and "Release branches" and create folders accordingly. So basically, a GitFlow organization would have these three folders: feature[s]
A branch is a version of your repository, or in other words, an independent line of development. A repository can contain multiple branches, which means there are multiple versions of the repository.
The now "slightly deprecated" use of .git/branches
is described in the useful gitrepository-layout
documentation:
branches: A slightly deprecated way to store shorthands to be used to specify URL to git fetch, git pull and git push commands is to store a file in branches/<name> and give name to these commands in place of repository argument.
In the comments above, the question was raise of why some people have this directory and some don't. It seems that a commit was introduced in 2009 that stopped git from creating the .git/branches
directory by default. However, more recently that change was reverted (i.e. meaning that the .git/branches
will be created on git init
, etc.), with the following justification from Junio C. Hamano:
There is not enough justification for doing this. We do not update things in .git/branches and .git/remotes anymore, but still do read information from there and will keep doing so.
Besides, this breaks quite a lot of tests in t55?? series.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With