Photo-1 Photo-2 Photo-3 Photo-4 Photo-5 Photo-6

@brentmc79

@brentmc79

Full-time web developer. Part-time smart ass.

I'm Brent Collier.

After a year and a half as an engineer on Twitter's Trust & Safety team, I'm looking for my next gig. Contact me if you know of something interesting.

#

Git checkout woes [updated]

Posted on 05/06/2009

I ran into a strange issue while attempting to checkout a remote tracking branch of an Intridea project earlier today, so I thought I'd post up my work around.

I ran my normal checkout command, like so...

brent:~/Intridea/earthaid[master]$ git checkout -b prod origin/prod

which resulted in this error message

fatal: git checkout: updating paths is incompatible with switching branches.
Did you intend to checkout 'origin/prod' which can not be resolved as commit

After a bit of googling, I'm still not sure of the cause as most of the search results were related to issues around deploying tags, and I was merely attempting a checkout.  What I did find out was that I could specify the start point of my new branch by the revision/commit sha instead of the remote branch name, like so...

brent:~/Intridea/earthaid[master]$ git branch prod 02314583a99abdc276cde968c20babbadd23
brent:~/Intridea/earthaid[master]$ gc prod
Switched to branch "prod"
brent:~/Intridea/earthaid[prod]$

Once I had applied my changes, I just had to make sure to push them to the proper branch.

[update]

farside_cartoon.jpg

Ok, I'm a retard.  About a minute or two after I typed up this post, it occurred to me that Git couldn't resolve the remote branch name because I hadn't pulled first.  Yeah, that's right.  All I need to do was pull and then everything worked properly.