Tag Archives: Branch

Git checking out a remote branch

I need to checkout remote branches from other repo’s quite a lot. Mostly these repo’s are forks from the repo that I’m on. An example of what I do to make this go smooth without having to create a local branch (which is based on the master).

git remote add janmoesen https://github.com/janmoesen/forkcms.git
git fetch janmoesen
git checkout -b janneman janmoesen/rewrite-navigation-cache-file

I now have a new branch ‘janneman‘ that does not contain any nasty merge commits because I checked it out in one step.

ps: I used to follow the steps on github.com to get a branch from another repo, but they make you create a branch locally before pulling from that remote branch. If you do so, you will get a merge commit and I don’t like that.