Reputation: 417
Hello can anyone tell me where the .gitconfig file reside, i mean what is the folder where this file should be stored. I am seeing the linux kernel tutorials from KernelNewbies at stuck where that file should reside. I am following this link http://kernelnewbies.org/FirstKernelPatch and under the heading setup git they tell me to make .gitconfig file now i dont know what should be the path.
Upvotes: 26
Views: 92825
Reputation: 488183
There are three (or if you count --file
, even four) places you can configure Git:
--system
. Unless you are the system administrator, you do not want to use this one.--global
. This is the one you want here.--local
, or without any --whatever
flag at all.The actual location of the user-specific file varies: the most common place is your home directory (~
or $HOME
) but there is this obnoxious XDG_HOME
thing, and this other obnoxious thing called Windows :-) , that can mess with this. So an easy way to avoid having to know where the file lives is to use git config --global
to set things.
My recommendation is to use git config --global core.editor name of your favorite editor
first, then to use git config --edit
to make sure that this actually works. For instance, if you prefer vim, run git config --global core.editor vim
. If you prefer nano, run git config --global core.editor nano
. If you like Emacs, or Notepad, or whatever, well, the pattern should be clear by now. :-)
Once you have set your core.editor
, using --edit
will make sure it really works, and you will be able to see the format for the settings file (it's basically an INI-style file). Make sure that whatever editor you use, it writes text files as ASCII if possible, or UTF-8 when needing auxiliary non-ASCII characters, not "RichText" and not UTF-16, and without using a pointless byte-order mark ("BOM"), as these will give Git heartburn.
Besides core.editor
(which you do not have to set, I just recommend it), you must set:
user.name "your name"
user.email [email protected]
and you probably should set:
core.pager "less -S"
color.branch auto
color.diff auto
diff.renames true
(or even to copy
)diff.renameLimit 0
merge.conflictstyle diff3
although all of these are matters of taste.
Once you have your core.editor
set, you can set these others with git config --global var.iable "value"
, or with git config --global --edit
. The quotes here are needed only if the value
is more than one word (contains whitespace) or needs other protection from the shell (has $
or *
characters in it, for instance). (And: using --edit
is particularly valuable when you have set something long and complicated, like an alias, and want to fix a small typo, or experiment, without having to re-enter the whole thing.)
Upvotes: 15
Reputation: 3149
Your global git configuration is written to ~/.gitconfig
.
To override git configuration on a per-project basis, write to path/to/project/.git/config
.
However, you don't have to edit configuration files directly. You can set global or local configuration variables on the command line. For example, to set the global user name, use git config --global user.name "your-username"
.
Upvotes: 41