Introduction To Git

Share on whatsapp
Share on facebook
Share on twitter
Share on linkedin

Git is a distributed version control system (VCS). Simply put it is a system that tracks changes to files in a project, which enabling us to record project changes and go back to previous versions. It is especially useful when working or collaborating on group projects. This is the major reason why programmers around the world use it.


Setting Up Git

The process for setting up Git is relatively simple. You just download the setup file for the latest version of Git for your OS, run the setup and follow the prompt. You can download the official setup from their  official website for free 

To test check if Git installed successfully on your PC run

git --version

If everything went well the version of git will be displayed. If not you can search online the error returned and hopefully you find a solution or you can contact me.

Run the following commands to identify yourself with Git. The purpose of this is to be able to be identified when you make a change; your name and email will the displayed in the git log.

git config --global "Your Name"
git config --global ""



When working with git there are two types of repositories local and remote repositories.

A local repository is one stored on your system, where you can work on local versions of your project. In order to create a local repository navigate to the folder where you want it located with your preferred terminal, then run the command.

git init

A remote repository is one stored on a remote server. It is good for working with teams and collaborating with others.

In this article I will focus on local repositories to know more about global repositories have a look at my blog post on the topic.



When working with repositories you can stage files this allows the files to be tracked for changes. You can add files individual or all at a time

git add <file-name> 
git add .



This is the process of saving all the changes and files to the git repository this can be done with the command

git commit -m "an short explanation here"


Status and log

Git gives us the ability to see which files and being tracked and which are not this can be done with

git status

We also have the ability to check your commit history with the command

git log

The git log command displays the details of each log with who made the change, the message, time and a commit hash which is auto-generated. To go back to a previous commit run the below command

git checkout <commit-hash>

To go back to the latest commit run

git checkout master


Ignoring Files

To let git know which files you want it to ignore in your project directory create a file called ‘.gitignore’. In this file on each line write the name of the folder or file you want ignored and it would not be staged.



Simply I put a branch is a way of maintaining different versions of a project. Typical the current version is the masters branch and you can create other branches for other versions or beta tests.

You can create a new branch with

git branch <branch-name>

To switch to a different branch you use

git checkout <branch-name>

If you want to create a new branch and switch to it use

git checkout -b <new-branch-name>

To merge a branch is to bring two branches together and update the files in one branch from the other. For example merging master branch with version 2 branch will updated the code in master with version 2. To merge a branch ensure you are in the master branch or the branch you want to update then run

git merge <branch-name>

To Delete a branch use

git branch -d <branch-name>


For further learning have a look at the following links


Other Blog Posts

Gotham Full Review

Gotham is an action crime television series produced by Warner Bros. Television. The show ran for 5 seasons from 2014 – 2019 with 100 episodes;

Read More

CryptoTab Browser

I just recently heard about a new way of mining bitcoin from a friend, CryptoTab Browser. It is a web browser very similar to Google

Read More