Git Is My New Best Friend
Sun Mar 29, 2020 · 439 words

I spent the last week at @ABConseils (The company hosting my internshipi ✌) trying to deploy a two-tier web application (frontend/backend) inside containers. Everything was working fine except for recaptcha. For some reason I couldn’t get it to work on my local setup. I spent two days (on and off) trying to.

After struggling a bit with this recaptcha problem I met with the team, and we agreed that in order to test what have been done, we will temporarily remove recaptcha from my local environement and reintegrate it later in next stages.

Fortunately, I could easily remove recaptcha from the frontend thanks to @Badr who had already implemented this feature before.

The only problem was that the feature was not yet introduced into the Master branch and thus I had to checkout the develop branch to get it. I checked out the develop branch and again I am stuck! this time, the problem was related to typescript versions. I tried many combinations in my Dockerfile, still couldn’t get the project to build. I looked a little bit in stackoverflow and found nothing helpful.

I am not a javascript/typescript expert. So I needed to do things another way.

THINK ! THINK ! THINK

Linux Thinking

git cherry-pick to the rescue

After a while I got this idea of using git to do the job. Since the code on the master branch worked fine for me, I checkout[ed] back, I created a new branch based on Master and borrowed the commit with the “optional recaptcha feature only” using:

git cherry-pick <commit-sha>

Now, I have a working version, with the Recaptcha feature I need in it.

Now that the frontend is working, let’s try backend. This time recaptcha is not willing to go away, I tried to disable it following @Badr’s instructions and nothing seemed to work.

Here we go again ! Git to the rescue.

Git revert is good too

Finally I decided to fix the problem using git again. I went through the git history and looked for the commit that introduced Recaptcha in the first place, and I git revert[ed] it.

git log --grep recaptcha
git revert <commit-sha>

Phew, recaptcha is gone, and things are working again (hopefully).

To sum up, Git is a very powerful tool, “thank you Linus”, full of great features that can save us time and make our live easier 😁.

Finally I’d like to thank @ABConseils for hosting my internship, and for their continuous support as well. I’d like to thank @Badr too, for answering my dumb questions about the project, you rock my friend ✌.

Thank you for reading, see you next time 👋.


back · About · Blog · TIL · Links · Projects · Contact ·