What is Git and how it works?

Git is a free and open-source Distributed Version Control System (DVCS), a tool to manage your source code within a development team.

It was developed by Linus Torvalds in 2005 who is also the creator of the Linux kernel. Git was his second big project which came into existence to manage his first big project i.e. Linux kernel. This helped to manage the Linux kernel code changes done by a team of thousands of people.

In a typical Centralized Version Control System (CVCS), the source code is maintained int the repository stored on a remote server. Git is termed as distributed because the source code repository is not only stored on the server but also stored on each development machine. The copy stored locally is called a local repository whereas the one stored on the server is called a server repository. Each developer can work on their local repository to commit (save) code changes locally. Once the changes are tested locally they can be merged into a server repository by performing a PUSH operation. Similarly, the latest code changes stored on the server can be fetched using a PULL operation.
What is Git and how it works
To use Git on the command-line you will have to download, install and configure Git on your computer however Git is available out-of-the-box in Mac machines. The Windows version of Git is called GitBash.

Git is the most popular version control system and almost all IDEs support Git out-of-the-box so we generally don’t require to execute the Git commands manually, but there are instances where we need to run Git commands from the terminal console.

You can also see the list of all Git commands by executing git help -a
You can also see the list of all Git concepts by executing git help -g

Most commonly used Git commands are listed below:

usage: git [--version] [--help] [-C <path>] [-c <name>=<value>]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p | --paginate | --no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           <command> [<args>]

Common Git commands are grouped together to use in different scenarios:

To start a working area:

   clone     Clone a repository into a new directory
   init      Create an empty Git repository or re-initialize an existing one

To work on the current change:

   add       Add file contents to the index
   mv        Move or rename a file, a directory, or a symlink
   reset     Reset current HEAD to the specified state
   rm        Remove files from the working tree and from the index

To examine the history and state:

   bisect    Use binary search to find the commit that introduced a bug
   grep      Print lines matching a pattern
   log       Show commit logs
   show      Show various types of objects
   status    Show the working tree status

To grow, mark and tweak your common history:

   branch    List, create or delete branches
   checkout  Switch branches or restore working tree files
   commit    Record changes to the repository
   diff      Show changes between commits, commit and working tree, etc
   merge     Join two or more development histories together
   rebase    Reapply commits on top of another base tip
   tag       Create, list, delete or verify a tag object signed with GPG

To collaborate:

   fetch     Download objects and refs from another repository
   pull      Fetch from and integrate with another repository or a local branch
   push      Update remote refs along with associated objects

See 'git help <command>' or 'git help <concept>' to read about a specific command or concept.

More on Git can be learnt from this article.

Git vs GitHub

What is Git?
Git is a free and open-source Distributed Version Control System (DVCS) used to manage source code. The term distributed in Git indicates that the repository is not only stored on the server but its copy is also stored locally in each development machines. The copy stored locally is called a local repository whereas the one stored on the server is called a server repository. User can commit (save) their code changes to the local repository until they are ready to move the changes to the server repository using a PUSH operation. Similarly, the local repository can be updated with the latest changes from the server repository using a PULL operation.

To use Git on the terminal console you will have to download, install and configure Git on your computer however 
Git is available out-of-the-box on Mac machines. The Windows version of Git is called GitBash.

Common Git commands and their use are explained in this article.


Git vs GitHub
What is GitHub?
GitHub is a web-based hosting service for Git repositories and is basically an SCM (Source Code Management). It provides a user interface to list branches created for Git and allows you to share your repository with others as well as access other repositories.

GitHub is used for access control and provide features like team management, bug tracking, code review, etc. A free account can be created on GitHub but it also offers Enterprise, Team and Pro accounts. GitHub Enterprise is hosted on the cloud and can also be deployed on-premise, Azure or AWS.


To move your project to GitHub, create the repository in Git and follow the steps listed here.


GitHub is not required to use Git. Git can be integrated with various web-based SCM such as GitHub, VSTS, GitLab and Bitbucket.