This is the second part of Git from ZERO to HERO. If you haven’t checked out the first part yet, please go and give it a read so that you get the maximum benefit.

Image for post

Photo by Lukas from Pexels

In my previous post, we covered some basic commands. In this post, we will learn some more along with some amazing concepts.

File Status Lifecycle

Image for post

We can understand the lifecycle with the help of an example. Imagine we have a project folder with index.html,style.css and app.js. the files are now in the untracked region. To start the tracking of the files we use the add command. Now all the files come into the** unmodified region**. If we bring changes to the style.css file, that file alone will come to the modified region. Now add command has to be used again to stage it.

After you commit the files a snapshot is created and the files become unmodified again.


Branching

A branch in git is a **movable pointer **that points to the snapshot of your changes. It is an independent line where the development work takes place. Every time you commit, the master branch pointer moves forward automatically. The default branch name in git is the master branch.

Image for post

In this diagram, the blue line is the master branch where the main development takes place. And while working in a project it is always advised to create a new branch and work on it instead of working on the master branch. This is because there are chances that you might mess up with the project while adding a new feature and the whole project will get affected.

So to tackle this problem we create new branches like the purple and **green **ones and work on them. The new branch will be an exact copy of the master branch. We can continue the work in this branch and if we are able to implement the feature successfully we can merge the branch to the master branch. In this way, the master branch will always be free from errors and we can have a smooth development workflow.

#commands #github #git #development #open-source

Git from ZERO to HERO — Leveling Up
1.30 GEEK