A Time Machine for Programmers.

Thekrishbhanushali
Ecuriosity
Published in
6 min readSep 4, 2020

An Intro to Git

Well First of all I would like to ask is Time Travelling possible ?

Well in a sense not! according to the current known science and possessed technology. But It is possible for Programmers. Yes The machine is known as “Git” which is free of cost.

How for Programmers ?

Now let us assume a Timeline from where we start doing a project,app anything any work. Now what we do is just keep on developing and go forward in our timeline. Suppose we run into an error and wish oh I wish I could go back in time and I would follow another route or do something else, rectify my mistake! (In Real life that would result in Grandfather’s Paradox).

Generally what modern development practices focus on Plan , Build , Test release small improvements to the product. Not like waterfall approach where many features are developed and released as one batch.

Git is a version control system or Time-Machine which keeps track of all of your small improvements and like a Time Machine we can go back and then come forward in our whole history so if I want to go back at a point I can go there and again create a whole new timeline.

Version control system are really important as they help to keep track of our steps and progress.

Git — open source version control system

So let us say I have 10 files of code for my app and I continuously want to improve this project solving one by one bug and adding new features continuously, So Every time I add something its basically a different minor version and Git manages this small changes and my versioning

Commit is basically each version of my project.

A->Blue colour app bar
B->Grey colour app bar

So B be new feature I introduced in A which already existed in my App and is part of my continuous development so this new version I can call it as commit.
So A and B are my different commits

Master Branch is basically a main timeline. Read more to know more
I will discuss all of them 😛

So I as told had 10 files and I only changed the colour to grey this may seem a small change in this perspective but we know these small changes make up our development in real there can be major bug fixes or complete new features in the commits

Here Commits A and B only differ by a single file I can say and Git is really helpful while doing this, it also gives us the opportunity to review everything every history to identify where we went wrong.

So Is Git efficient The major question that comes to our mind?

Since we can say commits are the snapshot of the whole project at that time so Does Git stores again the 10 files at B that means 20 files and this is not efficient

Basically this is not what happens. Git creates an additional file that is just one file which contains the bug fix. I will go to this how it works later. Collection of commits signify our whole journey. Just like what we did all our way each and every changes. So what if people didn’t like the grey colour of the app bar well its okay I would go back to my change or commit A simple or I would introduce a new commit.

So how do we use it as collaborative tool?

Well it comes up with a concept of Branching. So lets again come to a Time Machine example , now lets say I have a Concert of Maroon 5 to go but the next day to it is an important Test. So I want to see in Future what will happen if I went to the concert without experiencing it in my current timeline. What I will do is just create a different route which wont affect the real me and travel through it. Later If I liked this route I could merge it with real me.

So In Git A branch can be thought of as an independent line of development of the project ,there is a main branch which is called master branch same as real me. Okay if I keep on changing the master branch my project wont be stable.

For example I am developing an app and I want a new feature suppose notifications these are considered as a new feature but I just don’t want to ruin it I mean I just don’t want that messes up with my current project same as I couldn’t just take risk with my real me , although I can go back and change but this is not good as taking a risk first and then change it.

Technically……

What I do is create a new branch lets call it pushfeature and what it will do is branch out a new path that is whenever I will commit a new feature my master branch wont get affected and it will simply be stable and all I am messing up with is my pushfeature. Here lets say my Commit C has a notification feature but my stable or master version doesn’t even know it exist or not and thinks okay B which just was a grey colour change is my latest commit.

So when we are working in Master branch sees Example 50 stable files and commits are thoroughly tested approved and then they are included in the master branch. So from above pushfeature sees same 50 plus one file with a feature I added new.

So now I have successfully implement my pushfeature commits. I am now ready to become a part of master branch so
A merge operation combines the work of separate branches and we will talk about it later. That is I have seen that yes this way was good now I am ready to do it by my real me. I would merge our timelines.

So since master branch doesn’t know about any of the commits in pushfeature how will it know that the changes are good?

So what I would do is do a pull request that is I am in pushFeature I will have a pull request to master branch that my change is complete so please include it in the master branch. So in real there are automated test before the merges allowed to happen to ensure that customer has no problem for it,when my pull request gets accepted

I basically contributed this feature to master branch and I will feel good to have introduced a quality of good changes in the open source ; )

This independence helps teams to separate development that is let us say my three other friends are collaborating with me ,would work on Bug fixes , few features , they would all work on their timeline and later If I like it I can simply merge it with my current timeline.

Well have patience , I will dive more deeply into Git and we will learn all the commands and best practices to use Git

…………………………………………………

and Guess Github too!

--

--