Git – Environment Setup and Basic Configuration

Installing git is easy with operating system provided packages like apt or dnf. We can track here Fedora way with dnf but it is very similar for other operating systems like CentOS, Debian, Ubuntu etc.

1

2

3

4

$dnf install git-y

Failed toset locale,defaulting toC

Last metadata expiration check:1:28:52ago on Thu Oct608:01:172016.

Dependencies resolved.

First-Time Configuration

After installing git making some configuration will make usage of the git more easy. System wide configuration is held in /etc/gitconfig .

But more practical configuration can be done in the users home directory. .gitconfig file stores user wide configuration and this configuration is used by all projects if project wide configuration is not exists.

1

2

3

4

$cat.gitconfig

[user]

name=John Doe

email=jdoe@poftut.com

And project specific configuration is held in the .git/config file.

User Configuration

As there will be a lot of commit in big repositories user tracking is important. We can set our name and email for the project but setting them globally will make it more practical because we are busy developers and programming a lot of different projects 😉

1

2

3

4

5

6

7

8

9

$git config--globaluser.name"John Doe"

$git config--globaluser.email"jdoe@poftut.com"

$git config-l

user.name=John Doe

user.email=jdoe@poftut.com

core.repositoryformatversion=

core.filemode=true

core.bare=false

core.logallrefupdates=true

We set our user name with config command for the –global and providing username and email values with user.name and user.email . After setting user info we can check with config -l command.

Initialize git Repository

Repository is the location where directory and related files reside. If we list files in the initialized path we can see that a hidden directory named .git is created. It is the core where magic happens.