Git

Git is an Open Source Distributed Version Control System.

Let's break it down and explain it:

  • Control System: This basically means that Git is a content tracker. So Git can be used to store content — it is mostly used to store code due to the other features it provides.

  • Version Control System: The code which is stored in Git keeps changing as more code is added. Also, many developers can add code in parallel. So Version Control System helps in handling this by maintaining a history of what changes have happened. Also, Git provides features like branches and merges, which I will be covering later.

  • Distributed Version Control System: Git has a remote repository which is stored in a server and a local repository which is stored in the computer of each developer. This means that the code is not just stored in a central server, but the full copy of the code is present in all the developers’ computers. Git is a Distributed Version Control System since the code is present in every developer’s computer. I will explain the concept of remote and local repositories later in this article.

Why we need a version control system like Git?

Real life projects generally have multiple developers working in parallel. So a version control system like Git is needed to ensure there are no code conflicts between the developers.

Additionally, the requirements in such projects change often. So a version control system allows developers to revert and go back to an older version of the code.

Finally, sometimes several projects which are being run in parallel involve the same codebase. In such a case, the concept of branching in Git is very important.

You can download Git from https://git-scm.com/

Git commands

Here are some Git commands that are regularly used.

Initializes a new Git repoository
git init
Bring up 21 most common Git commands
git help
To know how to use and configure a specific Git command
git help init
It brings new files to Git's attention
git add 
Check the status of your repository
git status
Short for "Configure", this is most useful when you're setting up Git for the first time.
git config
Commit will take a snapshot of the repository
git commit
The -m indicates that following section of the command should be read as message
git commit -m "Hello World!"
This command will let you build a new branch, or timeline of commits, of changes and file additions that completely your own.
git branch 
Literally allows you to "check out" a repository branch that you are not currently inside.
git checkout name_of_branch
The -b indicates to create a new branch and the same time check out ot that branch
git checkout -b "New branch"
You can merge your changes back to the master branch or the branch of your choice
git merge
To make your work on your local computer visible online on GitHub
git push 
This update your local repository with changes from GitHub
git pull

Last updated

Was this helpful?