Since it is the month of all things spooky, I thought it would be a good idea to post one of my scary experiences while developing, to get into the mood of Spooktober.
This scary experience comes in the form of git. So here's the story...
I was placed on an Android project, where I had to add a new feature and apply flavour specific resources. So the first thing to do was to clone the project. Alright, I've done that before so it shouldn't be an issue. Oh was I wrong. The project source resides on BitBucket and I make use of Git Bash terminal to clone and to run other commands. I go to BitBucket and choose the develop branch (see image below), then proceeded to press the "Clone" button, pasted the link into my terminal.
The develop branch on BitBucket.
At this point, all seems well. I then proceed to Android Studio to open up the project to make sure that it builds. The project runs a successful build. I go back to my terminal again to run $git status to see the status of the branch I'm currently in. I then noticed that I'm in master. I then run $git checkout develop . It returns a message that states that the branch does not exist.
How can this be possible as it exists on BitBucket.
I repeat the whole process again, hoping for a different outcome. I still encounter the same issue. I ask a colleague if he has a successful clone. He says no. I then wonder if we were given the correct access rights on BitBucket...
But that wouldn't be the cause because I could view all of the branches. At this point I'm too shy to approach my manager for this silly situation.
Next step: Dig up solutions on Stackoverflow.
I Googled my issue, found some suggested solutions on Stackoverflow. The first few solutions didn't work at all. I digged deeper, and finally a solution that worked. The command is $git clone -b .
Some of the reasons why I did not approach my senior/team lead initially was because:
- I wanted to should show attempts in trying to solve my issue.
- It felt embarrassing, as I am a junior dev. And I've been working with git commands for 3 years so far.
Lessons to take away:
- Attempt to solve an issue before you approach a team mate.
- Do not spend too long on trying to solve an issue.
- Alert your team mates of the issue in time.
- Share your solutions with the community.
Which git commands do the trick for you?
Cover Photo by Ehud Neuhaus on Unsplash