Git and Github

What is GIT?
Git is an open-source version control system that was started by Linus Trovalds—the same person who created Linux. Git is similar to other version control systems—Subversion, CVS, and Mercurial to name a few.

What is Github?
GitHub, a subsidiary of Microsoft, is an American web-based hosting service for version control using Git.
The social networking aspect of GitHub is probably its most powerful feature, allowing projects to grow more than just about any of the other features offered. Each user on GitHub has their own profile that acts like a resume of sorts, showing your past work and contributions to other projects via pull requests.

Git Tutorial – Operations & Commands
Some of the basic operations in Git are:

  • Initialize
  • Add
  • Commit
  • Pull
  • Push

Some advanced Git operations are:

  • Branching
  • Merging
  • Rebasing

A brief idea about how these operations work with the Git repositories. Take a look at the architecture of Git below:

Git Architechture - Git Tutorial - Edureka
Source: Edureka website

In order to do that, we use the command git init. Please refer to the below screenshot.
# git init

Git status
The git status command lists all the modified files which are ready to be added to the local repository.
# git status

This command updates the index using the current content found in the working tree and then prepares the content in the staging area for the next commit.
# git add <dir> or # git add <filename> or # git add -A (to add all files)

It refers to recording snapshots of the repository at a given time. Committed snapshots will never change unless done explicitly.
# git commit -m “some message”

Set your central repository as origin using the command:
# git remote add origin <link of your central repo>

# git pull origin master
This command will copy all the files from the master branch of remote repository to your local repository.
# git pull origin <branch name>

# git push <remote repo>
Note : This remote refers to the remote repository which had been set before using the pull command.

Branches in Git are nothing but pointers to a specific commit. Git generally prefers to keep its branches as lightweight as possible.
There are basically two types of branches viz. local branches and remote tracking branches.
To create branch
# git branch <branch name>
To switch branch:
# git checkout <branch name>

Merging is the way to combine the work of different branches together. This will allow us to branch off, develop a new feature, and then combine it back in.
# git merge <destination branch name>

It is important to know that the branch name in the above command should be the branch you want to merge into the branch you are currently checking out. So, make sure that you are checked out in the destination branch.

This is also a way of combining the work between different branches. Rebasing takes a set of commits, copies them and stores them outside your repository.

The advantage of rebasing is that it can be used to make linear sequence of commits. The commit log or history of the repository stays clean if rebasing is done.
# git rebase master

Few other commands:
To view commit logs
# git log

To configure profile:
# git config –global “[email protected]
# git config –global”avishek behera”


Leave a Reply