What is Git, GitHub and GitLab?

Posted on 18-Oct-2018 08:21:31

A number of developers today use Git as a version control system. And it is only growing each day. GitHub is used by about 31 million developers across individuals and 2 million organizations. GitLab is on the other hand is used by more than 100, 000 organizations.

In this post, I will cover what is Git, basic Git commands and what are the differences between GitHub and GitLab.

What is Git?

Git was originally developed in 2005 by Linus Torvalds, the creator of Linux Kernel and it was used to maintain the code of Linux Kernel itself. What makes Git so special is that it is a distributed version control system (DVCS). By distributed, what it means is that every Git repository that is cloned onto any system is a full-fledged repository with complete history and versioning. Different versions can be checked in the local system without interacting with the Git server.

In addition to being a DVCS,

  • Git is optimized for performance in terms of the different actions developers take.

  • Git compares the contents of files while they are committed as opposed to comparing content based on file names. For example, if you had to rename a file, Git will only commit the fact that there was a file renamed and maintain the version history accordingly as opposed to creating a new file and with a version starting from 1.

  • Git is secure. The directories, relationships, versions, tags etc are all stored with a secure hashing algorithm called SHA1.

  • Git is cool when it comes to creating tags, branches from tags, merging, reverting, etc. Though it might be confusing in the beginning to understand these terms but once you are used to those, it is easy.

Basic Git commands

Checking git is already installed.

git --version

To check out a branch, eg: master.

git checkout master

To pull latest changes from master.

git pull origin master

To create a branch.

git checkout -b <branchname>

Get an existing branch and work on it.

git checkout <branchname>

To view the status of your changes. Un-staged changes will show up in red and staged changes will show up in green.

git status

To stage all your changes.

git add .

To commit the changes.

git commit -m comment for the commit

To push your branch to remote.

git push origin <branchname>

Merge changes with master.

git checkout master

git merge <newbranch>

Once merged, push the master also to remote.

git push origin master

Unstage all changes.

git reset .

To undo recent commit.

git reset HEAD~1

What are the differences between GitHub and GitLab?

GitHub and GitLab are Git based repositories at the base. They now provide a number of features beyond the basic Git DVCS. Here are some key differences.

Public vs Private repositories

Both GitHub and GitLab offer public and private repositories. However, GitLab offers private repositories for free but GitHub provides it at a minimum of $7 per month. I was a fool who didnt knew this and paid for private repository in GitHub for few months :) Finally migrated to GitLab when I knew this.

Web vs Self hosting

Both GitHub and GitLab provide web and self hosting. But GitHub provides self hosting only for enterprise plan.

Project Management

Both GitHub and GitLab offer tools for issue tracking, assignment, etc However, GitLab provides further features in enterprise plans to create epics within projects. Very useful when the product backlog is huge under different themes/epics.

Continuous integration/continuous deployment (CI/CD)

This is the big one. GitLab has its own built in ci/cd and now calls itself as a single complete DevOps application beyond just a DVCS. With GitHub you can integrate with third party tools like Jenkins, etc.

However, with Microsoft acquisition of GitHub earlier this year, we have to see how GitHub grows further in terms of its features.

Would you like to get notifications about New Blogs?