Tuesday, March 1, 2011

git bare repos

A normal git repository is a directory that contains:
  1. Our files: Files and directories that we have created and which contain our data. These files and directories are collectively known as working tree.
  2. .git directory: This folder contains all of the Git's control files.
A bare git repository does not have working tree and it also does not have .git directory either. All of the Git's control and management files are present in the directory directly. You can not checkout from a bare repository or commit to it.

So what are they useful for when you cant checkout or commit to them?

Bare Git repos are good for pushing and pulling only and they are designed this way so that they can be used as common shared repo by a group of people. So any one want to make changes makes a clone of that bare repo, makes changes in that cloned repo, commit them there and then push the changes to bare repo. Now any one wanting those changes can pull them from the bare repo.

To create and initialize a new bare git repo you can use the command:
git --bare init
and to clone an existing repo as a bare repo use:
git clone --bare

No comments: