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?)
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?)
It will create your repository in the .git folder in the current directory.
ls -ld .git when in ~?~/common/.git (common is the name of the package). I reckon GIT stores unfinished jobs in a temp folder and upon success it transfers back to current directory. I just hope it has deleted nonsuccessive downloads.To be a bit more complete, Git works with:
git init).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 fieldThe 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.
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\ HOME directory of git bash. If you change directory, of course the cloned repositories get created in the directory you are calling git clone from. What actually answers the question is that git stores the files in a folder called .git inside the repository, wherever you have chosen to clone it.Windows 8.1 : C:\Users\user_name\.project_name or call from Run ...\.project_name.In the root directory of the project there is a hidden .git directory that contains configuration, the repository etc.
ls isn't enough. You gotta run ls -a to view hidden files too.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.
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!
Program Files, which is common to all users. Windows will instead create the file in the user's VirtualStore folder. The simplest solution is to avoid creating files in restricted folders and instead create them somewhere like in Documents.