26

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.

3
  • I don't have a branches directory in any of the checkouts I have to hand (all git 1.7.9 I think) - maybe it's deprecated and now gone? Commented May 1, 2012 at 13:23
  • git 1.7.9.5, 1.7.9.1, 1.7.5.4 and I always get a branches folder, though empty. Commented May 1, 2012 at 13:27
  • I could not find any better reference than this link, which confirms that it is a deprecated way to ref branches. Commented May 1, 2012 at 13:34

1 Answer 1

21

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.

Sign up to request clarification or add additional context in comments.

1 Comment

The link to the git repository layout documentation is no longer working. Do you know if it's available somewhere else? EDIT: nvm, I found it. git-scm.com/docs/gitrepository-layout

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.