Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the .git/branches folder used for?

Tags:

git

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.

like image 922
Alexander Bird Avatar asked May 01 '12 13:05

Alexander Bird


People also ask

What is a branch folder?

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.

What is the use of branches?

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.

Is a Git branch a folder?

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]

What are branches in a repository?

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.


1 Answers

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.

like image 134
Mark Longair Avatar answered Oct 18 '22 03:10

Mark Longair