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.

  1.  /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.
  2. ~/.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.
  3. 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

Chapter 1. Git for beginners

What is Git.?

Git is a distributed version control system. Git is a mature, actively maintained open source project originally developed in 2005 by Linus Torvalds, the famous creator of the Linux operating system kernel. To know more about Git click here…

Getting Started with Git:

  1. Create an account on Github.com:

a. Go to Github.com and Sign-up:

         b. Create a new(remote)repository for your project:

2. Create a new(local)repository:

         a.  Create a folder/directory:

$ mkdir git_demo

         b.  Open it and perform:

$ git init

3. Clone newly created repository(remote):

$ git clone https://github.com/<git-username>/my_repo.git

4. Create or add an existing file to the repository(local):

$ git add <file-name>  # for single file.

$ git add *               # for all files present in directory

$ git status

5. Commit changes to the repository(local):

$ git commit -m “Commit Message”

$ git log   # press ‘q’ for exiting from log

6. Pushing changes to the repository(remote):

$ git push origin master     # we are pushing changes to our remote master branch.

The second chapter will be adding shortly, stay connected…

Please Like, Comment and share it. 🙂