37

Spooktober: Git Horror Story

 5 years ago
source link: https://www.tuicool.com/articles/hit/QBnyEfB
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

y2YzQvQ.jpg!web

Since it is the 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.

fIBrU3j.png!web
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:

  1. I wanted to should show attempts in trying to solve my issue.
  2. 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:

  1. Attempt to solve an issue before you approach a team mate.
  2. Do not spend too long on trying to solve an issue.
  3. Alert your team mates of the issue in time.
  4. Share your solutions with the community.

Which git commands do the trick for you?

Useful links:

Cover Photo by Ehud Neuhaus on Unsplash


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK