Guy E
Guy E

Reputation: 1927

GIT local repository

I'm trying to figure out what is the "local repository" vs my local files I'm working on, seen in the file system (what is known as the "workspace" in other source controls tools). For further explanation: Lets say my local code is located at: c:\users\A\ documents\GitHub\. After changing one of the files, I can commit the changes into the main branch (currently the Master) in my "local repository" - where is the "local repository" actually located ?

Upvotes: 3

Views: 260

Answers (4)

Ishan Thilina Somasiri
Ishan Thilina Somasiri

Reputation: 1244

As described by Roland Smith above, the local repository data is stored inside the .git folder in the repository folder (GitHub in this case).

For further understanding let's check the contents of that folder.

$ ls -C .git
COMMIT_EDITMSG  MERGE_RR    config      hooks       info        objects     rr-cache
HEAD        ORIG_HEAD   description index       logs        refs

I'll not be describing all the items in the folder. But the folder of interest is the objects folder. If you check the contents of the objects folder,

$ ls -C .git/objects
09  24  28  45  59  6a  77  80  8c  97  af  c4  e7  info
11  27  43  56  69  6b  78  84  91  9c  b5  e4  fa  pack

It contains a lot of folders named with two characters. The first two letters sha1 hash of the object stored in git are the directory names.

I'll not go in to describe how those object files are generated. There a good guide from GIT for that.

Hint : If you want to know more details of the other files in the .git folder, check http://gitready.com/advanced/2009/03/23/whats-inside-your-git-directory.html

Upvotes: 0

VonC
VonC

Reputation: 1323115

You can have more details in the "Discussion" section of the git man page:

A Git project normally consists of a working directory with a ".git" subdirectory at the top level.

(a hidden folder in Windows: do a dir /AH in c:\users\A\ documents\GitHub to see it)

The .git directory contains, among other things, a compressed object database representing the complete history of the project, an "index" file which links that history to the current contents of the working tree, and named pointers into that history such as tags and branch heads.

The object database contains objects of three main types: blobs, which hold file data; trees, which point to blobs and other trees to build up directory hierarchies; and commits, which each reference a single tree and some number of parent commits.

You can change that default location (of the local repository) with the --git-dir option or the GIT_DIR environment variable.
I have recently proposed that in a Go development environment.

Upvotes: 1

Roland Smith
Roland Smith

Reputation: 43495

The repository for c:\users\A\ documents\GitHub is in a hidden subdirectory c:\users\A\ documents\GitHub\.git.

Upvotes: 1

Vikramjit Roy
Vikramjit Roy

Reputation: 484

Local repository is located in your machine. When git push your changes your local changes from your machine are updated on the remote repository which is present in Gothic.

Upvotes: 0

Related Questions