The .git Directory

If you haven’t explored the .git directory yet, it’s worth the hike. Do a cd .git in your local git repository that you’ve cloned from a remote repository and you should find something similar to this:

.git

A brief explanation of the various files and directories:

refs/remotes/origin/mastertext file6975b25be537f997c92490c7927cb6886fd5c49fThe most recent commit on this branch. Note the hash is the same as in refs/heads/master which means the user has merged the commits from this remote-tracking branch into the user’s master branch.

File/directory Type Value Meaning
config text file [See diagram] The configuration file for the local git repository
HEAD text file ref: refs/heads/master Lists a file to read that is the current HEAD branch: git branch will show the branch that HEAD refers to as the current branch.
refs directory Everything under the refs directory is references to a commit for a branch of some type (either a local branch or a remote tracking branch).
refs/heads directory Files in the refs/heads directory are branch names. For example a file named refs/heads/master means a branch named master exists in the local repository. The contents of the file is the hash of the most recent commit on that branch.
refs/heads/master text file 6975b25be537f997c92490c7927cb6886fd5c49f The most recent commit on this branch (master)
refs/heads/v1 text file fd70e1d85320d12f230d8ff5e6056d86a775a6f3 The most recent commit on this branch (v1)
refs/remotes directory Everything under the refs/remotes directory is references to a commit for a remote-tracking branch.
refs/remotes/origin directory The remote tracking branches for the remote repository origin are stored in this directory.
refs/remotes/origin/v0 text file e018ab5fe997a56bffb39350543c017684cfd721 The most recent commit on this branch. Note the hash is the different than the hash in in refs/heads/v1 which means the user’s local v1 branch is behind the commit in the remote-tracking branch’s v1 branch. The user needs to merge the commits from this remote-tracking branch into the user’s v1 branch to catch up to the remote-tracking branch.

Recent Articles

Where Do I Get Git?

Where do you get git? We have the answer to that for Linux (Ubuntu, Debian, and Red Hat), Windows, and Apple OS as well as over 30 free git tutorials.

What is the deal with the Git Index? What is the Git Index?

The git "index" is where you place files you want committed to the git repository. Learn more about the git index and git commit by selecting this link.

What Every VCS Must do

Version Control System ("VCS") need to be able to provide to its users? GitGuys explains exactly what it needs to include and provides tutorials on Git.

Visualising Branches And Their Commits

We explain and discuss the use of the git show-branch, gitg, gitk and qgit in this Tutorial. Complete with examples.

“Tracking Branches” And “Remote-Tracking Branches”

Both Tracking Branches and Remote Tracking Branches are created on the git client when a git clone command is used.

Related Stories

Leave A Reply

Please enter your comment!
Please enter your name here

Stay on op - Ge the daily news in your inbox