Where does Git store files?

Git

Git Problem Overview


I just ran the following commands on my Ruby on 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?)

Git Solutions


Solution 1 - Git

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

Solution 2 - Git

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 repository (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.
git 2.9 (June 2016) allows to configure that.


Note that Git 2.18 (Q2 2018) is starting the process to evolve how Git is storing objects, by refactoring the internal global data structure to make it possible to open multiple repositories, work with and then close them.

See commit 4a7c05f, commit 1fea63e (23 Mar 2018) by Jonathan Nieder (artagnon).
See commit bd27f50, commit ec7283e, commit d2607fa, commit a68377b, commit e977fc7, commit e35454f, commit 332295d, commit 2ba0bfd, commit fbe33e2, commit cf78ae4, commit 13068bf, commit 77f012e, commit 0b20903, commit 93d8d1e, commit ca5e6d2, commit cfc62fc, commit 13313fc, commit 9a00580 (23 Mar 2018) by Stefan Beller (stefanbeller).
(Merged by Junio C Hamano -- gitster -- in commit cf0b179, 11 Apr 2018)

> ## repository: introduce raw object store field

> The raw object store field will contain any objects needed for access to objects in a given repository.

> This patch introduces the raw object store and populates it with the objectdir, which used to be part of the repository struct.

> As the struct gains members, we'll also populate the function to clear the memory for these members.

> In a later step, we'll introduce a struct object_parser, that will complement the object parsing in a repository struct:

> - The raw object parser is the layer that will provide access to raw object content,

  • while the higher level object parser code will parse raw objects and keeps track of parenthood and other object relationships using 'struct object'.

> For now only add the lower level to the repository struct.

Solution 3 - Git

If you are on an English Windows machine, Git's default storage path will be C:\Documents and Settings\< current_user>\, because on Windows the default Git local settings resides at C:\Documents and Settings\< current_user>\.git and so Git creates a separate folder for each repo/clone at C:\Documents and Settings\< current_user>\ and there are all the directories of cloned project.

For example, if you install Symfony 2 with

git clone git://github.com/symfony/symfony.git

the Symfony directory and file will be at

C:\Documents and Settings\< current_user>\symfony\

Solution 4 - Git

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

Solution 5 - Git

I'm on Windows and found my location by right clicking the Git Bash program in my Start menu and selecting Properties. The Shortcut tab shows the "Start in:" value. For me, it was %HOMEDRIVE%%HOMEPATH%, so I opened a CMD prompt and typed echo %HOMEDRIVE%%HOMEPATH% to see the actual location.

Solution 6 - Git

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.

Solution 7 - Git

I also couldn't find my git repository. I am using Windows 8 and created my repository (by mistake) under C:\Program Files (x86)\Git. I could see the repository folder in bash but not in cmd or Windows Explorer.

Then I remembered about Windows's "Virtual Store" feature. My repository folder was actually created under C:\Users\<username>\AppData\Local\VirtualStore\Program Files (x86)\Git\<myrepo> and in there was my .git folder!

Solution 8 - Git

If you are looking for where the project folder was created. I noticed when I typed in the git bash.

$ git init projectName

it will tell me, where the project folder is for that project.

Solution 9 - Git

For me when I run git clone, Git will store the cloned package in the directory that I am running the command from.

> - I use windows.

for example :

C:\Users\user>git clone https://github.com/broosaction/aria

will create a folder:

 C:\Users\user\aria

Solution 10 - Git

it may created but it still hidden to show it go to your file explorer setting go to (view) then check the box at hidden item and go to your repository and refresh it and the

Solution 11 - Git

usually it goes to Documents folder in windows : C:\Users<"name of user account">\Documents\GitHub

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionYuval KarmiView Question on Stackoverflow
Solution 1 - GitMatthew FlaschenView Answer on Stackoverflow
Solution 2 - GitVonCView Answer on Stackoverflow
Solution 3 - GitVishal BandreView Answer on Stackoverflow
Solution 4 - GitBrenton AlkerView Answer on Stackoverflow
Solution 5 - Gituser2271109View Answer on Stackoverflow
Solution 6 - GitPeter TillemansView Answer on Stackoverflow
Solution 7 - GitbouvierrView Answer on Stackoverflow
Solution 8 - GitJason LamView Answer on Stackoverflow
Solution 9 - GitBruce MubangwaView Answer on Stackoverflow
Solution 10 - GitAymnView Answer on Stackoverflow
Solution 11 - GitShabbarView Answer on Stackoverflow