Spooktober: Git Horror Story

Pabi Moloi, but Forbes on October 28, 2018

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 t... [Read Full]
markdown guide
 

It felt embarrassing, as I am a junior dev. And I've been working with git commands for 3 years so far.

Don't worry, we all forget commands :-)

The thing is git clone creates a copy of the repository on your local machine pointing to the HEAD. In this copy you have the entire history and all the branches, develop included.

Once cloned you could have switched branch from master to develop by issuing: git checkout develop

git clone -b develop URL is, I think, a shortcut of the two commands.

 

Once cloned you could have switched branch from master to develop by issuing: git checkout develop

That's what they described doing, isn't it?

 

Yeah, I forgot about the origin part :-)

Johanathan's answer is more complete

 

I've been working with git for 6 years now and I've had some major nightmares over the years. Hours or days of code gone in one swift enter key stroke.

I've learnt one git command that's since saved me from those nightmares:


git reflog 

It keeps a local history of all the changes to a repo. So even if you screw up your branch, the commit is still there and can be found and restored using reflog.

 
 

Or simply do: git checkout -b develop origin/develop

The problem you encountered is that clone does not create local tracking branches automatically. See the first line in the clone documentation (always should be your first stop when troubleshooting Git): git-scm.com/docs/git-clone#_descri...

 

Hey Jonathan,
Thank you for sharing that link and taking the time to read.
:)

code of conduct - report abuse