Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

curious: where does git store user information?

Tags:

git

I'm wondering where does git stores user information. I created a repository, which both me and my friend works on. When we both commit, we can see both of us as individual authors for different revisions. while theres a .gitconfig file created using git config --global in his home folder, I couldn't find one in mine. So where's my user information stored? Does git config --global only affect the individual login user?

like image 933
goh Avatar asked Sep 07 '11 04:09

goh


People also ask

Where does Git store information?

Within a repository, Git maintains two primary data structures, the object store and the index. All of this repository data is stored at the root of your working directory in a hidden subdirectory named . git.

How is Git data stored?

Git doesn't think of or store its data this way. Instead, Git thinks of its data more like a set of snapshots of a mini filesystem. Every time you commit, or save the state of your project in Git, it basically takes a picture of what all your files look like at that moment and stores a reference to that snapshot.

Where is Git commit ID stored?

All git database is stored in . git/objects directory. You can find the commit in there. Just split the first two letters of commit SHA and look for a directory of that name.


4 Answers

There are 3 default paths for the config file.

  • Repository itself: <your_git_repository>/.git/config
  • User home directory: ~/.gitconfig
  • System-wide directory: $(prefix)/etc/gitconfig

The --global option always use the home directory. Note that git will always try to read all of them. If it finds one, it loads it, and moves to the next one. Local takes precedence over global, which takes precedence over system-wide. It uses a simple key-merging algorithm.

Reference: git-config FILES

like image 52
jweyrich Avatar answered Oct 24 '22 02:10

jweyrich


If you do not store user information in your configuration files Git looks in the environment for committer information, using the variables GIT_COMMITTER_NAME, GIT_COMMITTER_EMAIL, GIT_AUTHOR_NAME, and GIT_AUTHOR_EMAIL. In absence of these variables, your username and host name are used to construct a value. So even without any user information stored in configuration files two users will have different committer information.

like image 35
Bombe Avatar answered Oct 24 '22 03:10

Bombe


There are three places - system ( all users on the system at $(prefix)/etc/gitconfig), global ( for the user at ~/.gitconfig) and local ( for the repo at .git/config). Any config should be in either of the three to be taken by git.

However if GIT_CONFIG or myriad other environment variable are set, some of the values will be coming from those. If you are not able to find what you want in any of the config files, or not even able to find these files, look at all GIT_* environment variables as the last resort.

More details here:

http://git-scm.com/docs/git-config#FILES

like image 24
manojlds Avatar answered Oct 24 '22 03:10

manojlds


In my case, I found my username in the ~/.git-credentials file. Hope this helps you. You can also list the configuration using:

git config --list
like image 27
Michael Behrens Avatar answered Oct 24 '22 01:10

Michael Behrens