Git Tutorial - Git Configurations #1 - Mostlikers

23 January, 2016

Git Tutorial - Git Configurations #1

There are three levels that the Git stores the configurations. System Level, User Level and Project Level Configurations.

1. System Level Configurations:

This is the largest level of configuration this configuration will apply to the every user of the computer. These are default configurations and can be overwritten.

Git Tutorial - Git Configurations
On Unix the configurations will be in the location /etc/gitconfig. In Windows it will be in Program Files \Git\etc\gitconfig.

Commands:
git config --system

2. User Level Configurations:

This applies to the single user, which most of us most of the time is working on a single machine.
On Unix this configuration will be in the user home directory in a file called ".gitconfig". In Windows it will be in the user directory, i.e., the home directory Documents and Settings > username folder > gitconfig  ( $HOME\.gitconfig).

Commands:
git config --global

3. Project Level Configurations:

Configurations applying to only to a specific project. You can put the configurations in the User Configurations. If there is something specific to a single project you can put it inside of the project. i.e., my_project/.git/config

Commands:
git config 

Examples to configure Git:

git config --global user.name "John Doe"
git config --global user.email "johndoe@domain.com"
git config --list

Result:
user.name = John Doe
user.email = johndoe@domain.com

To see the Location of git:

Go to user directory by typing
cd ~

Then type
ls -la

You'll find the list as below or a list which is must be similar

drwx------   2 SystemName SystemName   4096 Nov 19 01:08 .filezilla
drwxr-xr-x   2 SystemName SystemName   4096 Dec 14 20:49 .fontconfig
drwxrwxr-x   2 SystemName SystemName   4096 Dec 14 20:49 .fonts
drwx------   4 SystemName SystemName   4096 Dec 20 22:10 .gconf
drwx------   4 SystemName SystemName   4096 Sep 26 12:19 .gegl-0.0
drwxr-xr-x  22 SystemName SystemName   4096 Dec 19 17:04 .gimp-2.6
-rw-rw-r--   1 SystemName SystemName     60 Dec 20 23:26 .gitconfig

You can see the .gitconfig file in the above list. Since it starts with a "." this will be hidden to the users.

To see whats inside the .gitconfig file type
cat .gitconfig

Result:
[user]
name = Arun Biradar
email = arunvbiradar@gmail.com

This is the minimum configurations required to start working with git. To make the other configurations you will have to come back to this file over time.

Other Configurations Required:

Tell the Git which text editor you will be using. This allows the Git to open up the text editor by default.
git config --global core.editor "'C:\Program Files\Sublime Text 3\sublime_text.exe' -wl1"

'-w' tell the Unix that after you launch the editor wait until the editing is done before you proceed.
'l1' to start at line one.

Next is to tell Git to use colors for better user interface
git config --global color.ui true

To check the configurations
cat .gitconfig

Result:
[user]
name = Arun Biradar
email = arunvbiradar@gmail.com
[core]
editor = vim -wl1
[color]
ui = true

Related Posts:

No comments:

Post a Comment