Contents

The mistake of not understanding git

Git plays a crucial role in the life of a software developer. I cannot imagine when code used to be shared by drives or disks with my fellow college mates for assignments. I learnt about git during my internship in 2015. And I thought of it as “yet” another tool to learn.

There have been countless posts by more experienced engineers highlighting the advantages of git and how to use it. Here, I will share what went wrong by not taking the initiative to understand the tool before working with it.

What happened?

I was learning to build iOS applications and got the idea which allow users to input long text and convert them to chronologically ordered 140-character tweets. In 2022 it is referred to as “threads” on Twitter. I don’t know if it was called the same in 2017.

I completed writing the algorithm which does the core work, and I tested that with the Twitter APIs. I had also finished designing the logo for the app and came across git versioning to keep track of the code on BitBucket. BitBucket was my choice because it was the provider which allowed private repositories without any additional cost. I knew only how to push my changes. I wanted to fix some commits, as I managed to commit private keys, which I didn’t want to. To fix them, I was mindlessly running commands found from StackOverflow and didn’t realise that I hadn’t pushed anything to BitBucket yet. I ran the hard-reset command on my local and reverted the changes. Also, I did something funky and removed all the locally committed files. By now, I had deleted the local code of my entire app. I had neither taken a backup nor committed them to Bitbucket.

What did I learn?

After countless hours, I was back to square one, but this time with a path to build the app. I tried to understand from my terminal’s history the commands I executed and their purpose. Even after so many pull requests, I am not confident about doing a reset on the git’s head. Coming back to the project, I proceeded with smaller commits and learnt about gitignore, which would prevent me from committing sensitive data. I started pushing the commits to my BitBucket repository more frequently. Fast forward to now, the changes I make are incremental and logical. So the key takeaway from this was to understand the code before executing and ensure you have a remote backup on GitHub / BitBucket.