Why do we use Git? Can we live without it?

When we start writing code, it is mostly single-file programs. We compile them with the locally installed compiler, run them with the command line, and observe the output. Almost all programming starts here.

Once we grow from this, we start writing programs that need more than one file. Very soon, it grows beyond the controls of simple file management and manual compilation; at this point, we need an IDE. An integrated environment that handles all the complexity of compiling, running, etc, and gives us a nice editor to write the code, highlighting the code on the way, giving us positive feedback on our program while writing.

We stay at this stage for a long time. For almost two to three semesters, we enjoy this stage. The IDE is our friend and we defend it on Reddit channels like anything. The IDE wars go hot, and we are almost on the verge of getting ready to physically beat people to make them endorse the same IDE. But after a few years, this obsession goes away, because with age comes wisdom.

Now we are at the stage where we need to make changes, comment out, delete code, test it. It does not run, and now we have to restore the file to what it was before. But we do not have that version with us. It is already gone.

What we need exactly in this scenario is an SCM. source code management tool. There is more than one tool available. But the most popular among us is “GIT SCM”.  https://git-scm.com/

This is a plain-text version management tool. We write code, once done, we add those files in staging. We double check that these were the changes we needed to do (GIT highlights the diff). We write a message (write proper git messages) and them run commit. That’s it.

It will save the diff of the text in a commit and give it a hash value for managing this commit – we can cherry pick, merge, or revert this commit using the hash. There are a ton of features available, I recommanded you to go and explore the man pages. https://git-scm.com/docs

Now you are fine with the git setup and write the code with more confidence as you know I can always revert it to previos version. You are happy, your teacher is happy.

After a few years, or at the door step of your university, you will get a job and you will become a software engineer in a company with multiple developers in a team. You need more collaboration, not just in real life but also in terms of writing software.

Git comes to the rescue again, with the remote repository configuration. There is a big repo hosted somewhere. we all cut a branch from there, work on this branch locally, test it, and push to remote. Raise a new PR to the target branch and send it for review. If all is well, your PR will be merged into the destination branch. Sometimes, you and another coworker will make changes to the same file. Your PR will be in conflict state, and you need to resolve this. But at the end, there is a  process where we know what the change is, who made it, and how to fix it. definitely not possible without a source code management tool.

Popular remote repository hosts are GitHub, BitBucket, and GitLab. You can also do some of them on your own (Your company will handle this; you do not need to worry, but for personal projects, I would not recommend hosting it yourself, as homelabbing is an expensive hobby, and saying from experience, you can buy a car for that money.)

Explore https://github.com/  https://bitbucket.org/product/

Now, let me share more stories around it. When production reports a bug, the first thing your lead will check is the git blame. Who made this change? Now, if your team is sensible, they will try to find the root cause of this and pick an available developer to fix it; otherwise, they will call you out of bed to first humiliate you and make you feel guilty and fix it in the next half an hour. So whatever you build, make sure you make it robust and cover all features.

Summary: There is no survival without Git in the current industry work environment. Learn it as early as possible in your studies and career. Here are some good learning resources. Happy learning.

Git explained in 100 seconds – youtube.com/watch?v=hwP7WQkmECE&pp=ygUDZ2l00gcJCQMKAYcqIYzv

Git and GitHub full course – https://www.youtube.com/watch?v=rH3zE7VlIMs

Pro Tip: Do not fight over tools and language wars. Work with whatever is available within your organisation and use it for building something that brings value to the customers. Tools do not matter much in the end.

Leave a Reply

Your email address will not be published. Required fields are marked *