Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find gitconfig file

Tags:

I just started learning about Linux and Git. Im using Linux Mint. I have Git and emacs installed via apt-get.

Im using the following tutorial https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup

it says that there are configuration files in three different places:

  1. /etc/gitconfig file
  2. ~/.gitconfig or ~/.config/git/config file
  3. config file in the Git directory (that is, .git/config) of whatever repository you’re currently using.

I have just started with Git so assume that option 3) is not applicable

I checked both 1) and 2) - i just cannot locate the files anywhere

I googled this with no luck and did sudo find . -name in the root directory

Have no clue what is happening as when i run this

$ git config --global user.name "John Doe" $ git config --global user.email [email protected] 

(i used my name surname above obviously)

it doesn't give me an error or anything - so where does it write this config data then?? where are these files?

like image 865
elnurcoot Avatar asked Sep 12 '15 12:09

elnurcoot


2 Answers

As confirmed by the OP, any git config --global command will create/update ~/.gitconfig.

But as it is an hidden file by default, you would need a ls -alrt to see it.
git config --global -l will list its content.

More generally, git config --list --show-origin shows all config files (and each line of the config data).
With Git 2.26 (Q1 2020), you can add a --show-scope option

git config --list --show-origin --show-scope 

That will also print the scope ("local", "global", etc) of all displayed config values.

like image 83
VonC Avatar answered Sep 19 '22 09:09

VonC


To find your global .gitconfig file:

  1. Open your terminal or command prompt
  2. Go to your root directory by typing cd ~
  3. Once in your root folder type ls -alrt
  4. You will see a .gitconfig file
    • To open your .gitconfig file type open .gitconfig

To find a particular repository's .gitconfig file:

  1. Open your terminal or command prompt
  2. Go to your repository's root directory by typing cd path/to/repository-directory
  3. Once in your repository's root directory type ls -alrt
  4. You will see a .git directory. Type cd .git
  5. Once in your repository's git directory type ls -alrt
  6. You will see a config file
    • To open your repository's .gitconfig file type open config
like image 38
BinaryJoe01 Avatar answered Sep 20 '22 09:09

BinaryJoe01