Git Version Control System

Hi readers,

Firstly I’d like to share my experience with git:

I started building projects during my 4th semester in my degree. At the initial days, I do not know about git I used to manage my code using the file manager. And also for one project ON SPOT ID Card Generator with Python which I worked with my friend we used to work with file manager and share code through email and we used to work like that. That time I do not know about Git and how to use it. Later on, while building more and more projects I got to know about Git and GitHub. Then I saw some youtube tutorials and learnt it. I also learned to use git during my intern at a startup managing different versions (branches) of the mobile app. After my learnings in git, for all my next projects I started using Git and GitHub. And then it became easier for me to work with my friends as a team and also managing the codebase, different versions, different app environments, store my code, contribute to open source, helps in the documentation of your project through the markdown files.

So, all the readers if you do not know about git. So start using it right now. It helps you in managing the codebase. Makes it easier to work together in teams. You Can maintain different versions of your project

Git makes development easier while working in teams and managing different version of your project.

From now on, I am going to give a small overview of git

Basically, Git is a distributed version control system for tracking changes in source code during software development. It is designed for coordinating work among programmers, but it can be used to track changes in any set of files. And it is open source.

  • 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 and manage code.
  • 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.
  • 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.

To get started with git follow the below link:

  • To initialize a local git repository in your project:
$ git init

Before committing to the local repo, code needs to be in the staging area. A staging area is a place which keeps track of all the files before being committed.

  • To add files to the staging area:
$ git add filename
  • To add all files in the directory use:
$ git add .
  • To commit the changes to the local repo use
$ git commit -m "Initial Commit"

-m option is used to specify the commit message

Status

$ git status

git status is used to find out information regarding what files are modified and what files are there in the staging area

Branches

Branches are needed to support parallel developments thereby enhancing developers to work together in a team

Create a New Branch:

$ git branch test

In order to switch to test branch use:

$ git checkout test

Initially, commit 1 and commit 2 were done in the master branch. After commit 2 a new Branch called “test” is created, and commit 3 and commit 4 are added to the test branch.

At the same time, a different commit 3 and commit 4 are added to the master branch. Here we can see that after Commit 2, two parallel developments are being done in 2 separate branches.

The “test” Branch and the “master” Branch have diverged here and have different code the code from “test” Branch can be merged with the “test” branch using ‘git merge’

Remote Git Repository

Each developer will work in their local repository but eventually, they will push the code into a remote repository. Once the code is in the remote repository, other developers can see and modify that code.

For remote repositories, we can use GitHub or BitBucket

A resource to learn git:

I also made a video on my YouTube Channel (Adding a Project to GitHub):

Thanks for reading

Cheers!

-Vasanth Korada

Simple and Efficient