Let’s GIT It!!!
By: Tanisha Bisht
Tags: Git, Getting Started, Basics, Github Actions, Github

BRANCHES AND REMOTE REPOSITORY

Well, you can imagine branches to be the timelines, and the commits to be the events that happened in that timeline.

The remote repository is nothing but the repository you have on your GitHub.

What’s the use of this remote repository?

Without it, you can’t make other people see the code because this provides you a way to make your code visible to everyone through the internet. So, GitHub could be said like a common repository dumping ground for all the developers to see each other’s codes.

IT’S STORYTIME AGAIN!

So far, we have been showing the final picture to our client through our local machine (means face to face). We have not yet made our pictures accessible through the internet.

You would want to make it public if you want to collaborate your work with other photographers, which is possible by using the remote repository. Let’s change our analogies a bit, and get to a more practical environment of actual coding from photography.

Let us assume you made your remote repository, which by default will have just one branch which is called the master branch. We can create new branches but again what’s the use?

Some might answer, we require it for collaborating in teams.

BUT Y?

Let’s get to our story, you are now working in a team and have to build a little application let’s say a simple website. You are three members in a team, and you want to split your task so let’s say student1 gets to make the navigation bar student2 gets to make the inside content and pictures of the about me page and the other student arranges the content and pictures for the contact me page.

Now without git how would you guys collaborate? How would you merge your code in the end? Would you send each other your code through mail or drive?? Would you manually go line by line and then find the contradicting code then merge? Isn’t it kind of time-consuming. TOTALLY!! It is!!!

Creating new branches in git is to our rescue!! Ok, we understood the problem area and know what the solution is but now how to apply the solution?

Well it’s simple, all three of them create their own new branches in their local machine, make required changes in them individually then they could push it to the remote repository then merge it.

REMEMBER: It’s important to first push then merge

How it should not be:

If we first merge the branch locally with the master branch then push the changes to the remote repository, this makes changes to the master branch of the remote repository which is accessed by other developers and they might not like the changes made by you.

How it should be:

Everyone should individually push their branch to the remote repository and then all the developers in the team could discuss which feature to keep and what not to keep and accordingly merge the branch with the master branch in the remote repository.

On merging their code, git does the hard work for us to find the places where changes are made and are contradicting our previous code and then we can manually go there and change it accordingly. On merging with the master branch git produces a commit called the merge commit.

By now we also understood the third point for our wiki definition of git that it’s designed to coordinate among programmers and track changes.