Chapter 1. Git for beginners (miscellaneous config)
An important basic configuration for git:
A. There is tool/command by using we can get and set configuration variables that control all aspects of how Git looks and operates, this tool/command is git config.
- /etc/gitconfig file: Contains values for every user on the system and all their repositories. If you pass the option –system to git config, it reads and writes from this file specifically.
- ~/.gitconfig or ~/.config/git/config file: Specific to your user. You can make Git read or write to this file specifically by passing the –global option.
- config file in the Git directory (that is, .git/config) of whatever repository you’re currently using: Specific to that single repository.
After installing Git, every Git commit uses basic information like username and e-mail address, and it’s immutably inserted into the commits.
B. Adding Username and e-mail address in git configuration:
- Set Username:
$ git config –global user.name <Full-Name>
Retrieve username as follows:
$ git config –global user.name
- Set E-mail address:
$ git config –global user.email <E-Mail Address>
Retrieve username as follows:
$ git config –global user.email
- Set color scheme:
$ git config –global color.ui ‘auto’
- Set default editor (this case setting ‘vim’ editor):
$ git config –global core.editor “vim”
C. At glance you can see the modified options in .gitconfig file:
- Example file looks like this:
$ cat ~/.gitconfig
# This is Git’s per-user configuration file.
[user]
# Please adapt and uncomment the following lines:
name = Satya4ever
email = satya4ever@example.com
[color]
ui = auto