tags:

views:

133

answers:

4

I just ran the following commands on my rails project:

git init
git add .
git commit -a -m 'Initial'

Where does git actually store this repository? (it's on my local machine, but where?)

Thanks!

+11  A: 

It will create your repository in the .git folder in the current directory.

Matthew Flaschen
+2  A: 

In the root directory of the project there is a hidden .git directory that contains configuration, the repository etc.

Brenton Alker
a hidden directory makes a lot of sense. That's what I suspected but I couldn't see it in Terminal. Apparently running `ls` isn't enough. You gotta run `ls -a` to view hidden files too.
yuval
That's correct. And hidden is defined simply as "starts with ."
Matthew Flaschen
That "dotfiles" are hidden is probably only obvious to those familiar with *nix based systems, but yes.
Brenton Alker
+2  A: 

In a .git directory in the root of the project. Unlike some other version control systems, notably CVS, there are no additional directories in any of the subdirectories.

Peter Tillemans
+5  A: 

To be a bit more complete, Git works with:

  • the working tree (the root of which being where you made a git init)
  • "path to the git repository" (where there is a .git, which will store the revisions of all your files)

GIT_DIR is an environment variable, which can be an absolute path or relative path to current working directory.

If it is not defined, the "path to the git repository" is by default at the root directory of your working tree (again, where you made a git init).

You can actually execute any git command from anywhere from your disk, provided you specify the working tree path and the git repository path:

git command --git-dir=<path> --work-tree=<path>

But if you execute them in one of the subdirectories of a git repo (with no GIT-DIR or working tree path specified), git will simply look in the current and parent directories until it find a .git, assume this it also the root directory of your working tree, and use that .git as the only container for all the revisions of your files.

Note: .git is also hidden in Windows (msysgit).
You would have to do a dir /AH to see it.

VonC