Your Version control — GIT

Your popular tool to manage a project. Wait Wait… Managing the code of your project. What is GIT?. It’s a version control for your code. Irrespective of working in teams or as an individual, it helps a lot.

How about working in a team of 6 – 8 developers?. How about you manage / share your code in between co-developers. Here you go, using GIT.

GIT is a version control where code can be added to the Repository. Repository is a space where you save all your code. Is it only adding files to Repository is GIT?. There are other uses as well.

You can have a controlled way of managing code with commits. You can create Branches as many to modify your Code, based on your requirements and merge them to Master. You can review your Code, raise a Pull Request and ask other developers to review code. Reviewing a piece of Code can be useful for learning as well. The committed Code can be reverted, if the Requirement changes or some thing goes wrong.

Let’s look at some basic things that are used via GIT.

Let’s assume, there is a project called ‘Trello Board’ which is a web app. When a project is set up in the Repository. The Branch name of the Repository is by Default ‘Master’. This is where Project Code is saved.

Let’s assume, We have some Requirements for the ‘Trello Board’. Let’s call them FeatureA, FeatureB, FeatureC.

First Clone the Master to your laptop / desktop. This is called your local branch and the branch ‘Master’ created on the Repository is called Remote Branch.

Command for Cloning a repository : git clone <URL>

You can find the http/ssh url in the repository website.

Now create a Branch called ‘FeatureA’ from master.

git checkout -b FeatureA

Now FeatureA is created from ‘master’ branch. Simply, FeatureA is a child/ replica of your Master (Local branch cloned from remote branch).

Now change your code or add new coding files. In order to look at the changes you have made. Use the following command.

git status — Displays the Branch name and the files that has been added or changed.

Now add your local changes to remote branch : Here are the few steps to be followed.

Add your files/ changes this can be done in two ways

  1. Add each individual file : git add <file path>
  2. Add all the file changes at a time : ‘git add .’

Now commit your changes with a commit message. This commit message will help to tell what are the changes thats been done for this commit.

git commit -m FeatureA added html files

Here FeatureA added html files — is a commit message.

As you have created the branch ‘FeatureA’ with command. Use the following command to push the code.

git push -set — upstream origin FeatureA

Else if the branch is created remotely (You can find an option to create a branch in repo website.)

Simply use : git push

Now your branch FeatureA is being pushed to the remote repository. Now create a Pull Request (PR)(This option is available at the version control website).

You can simply merge your changes to the Master branch.

Full stack developer, Blogger, Poet, Writer

Full stack developer, Blogger, Poet, Writer