Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is my .git/refs/heads/master file

Tags:

git

I am following below article to get some idea of internals of git.

http://git-scm.com/book/en/v2/Git-Internals-Git-References

It says that git stores references to latest commit objects of each branch in .git/refs/heads directory.

In one of my git repositories, I found that there's nothing in .git/refs/heads directory. All other repositories I checked contain files for each branch in the repository.

This repository with empty .git/refs/heads actually has a master branch and it works perfectly.

Can someone explain why.git/refs/heads is empty and how git works without a problem in this condition?

like image 392
Lahiru Chandima Avatar asked May 09 '15 14:05

Lahiru Chandima


People also ask

Where can I find Git refs heads?

You can view your repository's heads in the path . git/refs/heads/ . In this path you will find one file for each branch, and the content in each file will be the commit ID of the tip (most recent commit) of that branch.

What is refs heads master in Git?

refs/heads/master is a branch in your working copy named master . Frequently that is a tracking branch of refs/remotes/origin/master because origin is the default name for the remote created by git clone and its primary branch is usually also named master .

What are Git refs stores?

A ref is an indirect way of referring to a commit. You can think of it as a user-friendly alias for a commit hash. This is Git's internal mechanism of representing branches and tags. The commit hash returned by the cat command should match the commit ID displayed by git log .


1 Answers

Then there's going to be a file named .git/packed-refs there too. When repository histories start getting really long, having hundreds of tags starts to slow things down, so git pack-refs will put them all in the packed-refs file.

Yay for going after the internals, you're going to be floored by how simple it is. It's usually worthwhile reading whatever docs come with a tool, you're in repository layout and core commands territory, plus, see the "see also" links at the bottom. You should also be able to get those with git help, I hope there's no distribution that omits the docs.

like image 71
jthill Avatar answered Nov 04 '22 09:11

jthill