Introduction to Git (With Workflow)

Rachit Chauhan
5 min readNov 1, 2020

Version Control System

First of all let’s discuss what is version control system, so basically it is a platform which let the developers to work together or to collaborate and also to maintain a history of there work.

Few points of VCS are as follows:

  1. Allows developers to work together.
  2. Proper backup of the software/project is maintained.
  3. If there is problem in the latest version we can easily rollback to its previous version.

There are two types of Version Control System

  1. Centralized Version Control System
  2. Distributed Version Control System

Centralized Version Control System

In this VCS there is a central server present in which all the developers commit it is also used for storing files and enables team collaboration.

But it has some disadvantages which are as follows:

  1. Single point of failure: It means that if the server is crash and there is no backup of data then we cannot retrieve the data.

2. If the server is down the developer cannot make changes in the directory or in the file until the server get up.

Then Distributed Version Control System takes place

Distributed Version Control System

Here are some of the advantage of the Distributed Version Control System

  1. First of all an individual can commit from any where.
  2. They can also mirrors the complete repository.

3. If the server is down then the repository from any other client can be copied back to the server to restore it.

4. You can perform various processes while you are offline such as commit, create branches, view logs and various other processes. You only need connection while you want to publish the repository and takes the latest changes.

What is Git?

Git is an open source tool, it uses a distributed version control system to store the files and maintain a complete history of the work.

Few advantages of git are:

It is light weight.

Since it is a distributed version control system so there is no chance of single point of failure.

It is secure because when a developer commit to a file then a SHA hash function is created which means it is impossible to change the file or to delete a file from the git database without knowing git.

What is a Blob in Git?

A Blob is each version of a file.

Workflow of Git:

  1. Download the Git tool from the internet according to the OS you are using, I am using windows for now.
  2. https://git-scm.com/downloads URL for download Git.
  3. Install it in your system provide it the workspace where you do all that stuff.
  4. When proper installation of the tool is done open git bash a terminal opens in front of you.
Git bash terminal

5. Move to the place where you want to work I am working in my drive E and create a folder in which all your files are stored.

6. Initialize the working directory using the git init command without initializing the file cannot be pushed to github.

7. After initializing, create a file using the command nano <filename>.

8. When the file is created then use the git add command the file is the working directory is changed to staging area.

9. Create a repository in github and copy its URL

10. After creating the repository there are some steps written on starting, when you create the repository the screenshot of that is provided below.

11. Use git status to check that whether the file is added or not if the file is added it will be in green color and all the files or directories which are not added are in red color.

12. Make sure you have given your credentials in git, if you haven’t given the credentials if will show the message that please tell who are you and also it provide the command in that message or you can manually verify the credentials.

13. After adding the credentials, again type the git commit command which will commit the changes.

Command for git commit: git commit -m “commit message”

14. If the git commit command work successfully if will show like this

16. Then do git remote add origin which will provide the path of your repository.

git remote add origin <URL>

17. Now, finally push your directory to github using the git push command.

Command: git push -u origin master

18. When you write the git push command it will ask for signing up your github account with the git and after that it will push your file to the github repository.

19. Check your Github Repository, it will show your file in the repository.

As you see that I have created two branch i.e. main and master

20. You have successfully pushed your file to github repository.

Thank you

Github Profile: https://github.com/chauhan2000

Linked in : https://www.linkedin.com/in/rachit-chauhan-014350166/

--

--

Rachit Chauhan
0 Followers

Currently, Pursuing Btech. from CSE-DevOps, a DevOps Enthusiast, a learner, a vlogger