About Git and Git-Hub

About Git and Git-Hub

What is Git?

Git is a version control system that means a way to track all the new changes that are being done in the project which is been placed in the central repository.

Workflow of Git

While working with Git on Linux distributions like CentOS, Debian, Fedora, Ubuntu, Amazon Linux…etc. We have to follow command modules such as apt, apt-get, and yum according to the particular flavours of Linux.

Here we will be having a look at commands used in the CentOS flavour of Linux i.e. yum module:

Below we will check commands used.

  1. A command used to install Git

    *#*yum install git

  2. A command used to initialize a project

    #git init

  3. A command used to check the version of Git

    #git -version

  4. A command used to create a file

    #mkdir <filename>

  5. A command used to add a file to the staging area

    #gitadd <filename>

  6. A command used to commit a file to the local repo

    #git commit -m “<your_msg>”

  7. A command used to add and commit a file to the local repo

    #git commit -am <filename>

  8. A command used to check the log of commits

    #git log

  9. A command used to check log in one line

    #git log-oneline

  10. A command used to move all files into the staging area

    #git add

Staging area

Staging area is files that are going to be a part of the next commit, which lets git know what changes in the file are going to occur for the next commit.


Branching allows you to duplicate the source code for yourself. You will then work on your own branch so your edits do not immediately affect the original source code.


The process of joining your branch with the original source code after complete testing.


#git config user.name ”<name>”

#git config user.email ”<mail>”

For Global Configuration

#git config — global user.name ”<name>”

#git config — global user.email ”<email>”

Branching Commands

To list the branches

#git branch

To create a branch

#git branch <branch name>

To switch to another branch

#git checkout <switching branch name>

To merge branch to master

#git merge <branch name>

Conflict Merge, Rebase, Cherry-Pick Commands

_To compare future branches with existing branches

#git config — global merge.tool vimdiff

#git config — global merge.conflictstyle diff3

#git config — global mergetool.prompt false

#git mergetool

_To Rebase

#git rebase master

_To Pick a specific commit of file

#git cherry-pick <id>

_To remove a file

#rm <filename>

What is Git-Hub?

GitHub is a cloud-based Git repository hosting service,similar to Dropbox or Google Drive.

It lets individuals and teams host their projects, work together on projects. GitHub works with Git to add more functionality. For example, store these Git repositories on their servers.

GitHub essentials are:

  • Repositories

  • Branches

  • Commits

  • Pull Requests

_Commands used to communicate git with GitHub

_To connect the remote repo to the local repo

#git remote add <repo name><repo link from github>

_To push code from local repo to remote repo

#git push <repo name> <master repo> or

#git push -u origin master

origin -> remote repo name

master -> local repo

_To pull from the remote repo

#git pull origin master

_To copy code as a local file

#git clone <repo link>

_To hold a file in the staging area before committing to the local repo

#git stash

_To revert the changes

#git revert

_To revert a particular commit

#git revert <commit>