Git Tracking Remote Branches

For some reason, I’ve always failed to remember what the command to track a remote branch is in git. I look it up on this page everytime I want to do it: https://git-scm.com/book/en/v2/Git-Branching-Remote-Branches

Well no more. I figured if I write a post about it, I will remember it so here we go:

[pastacode lang=”bash” message=”” highlight=”” provider=”manual”]

git fetch origin
git checkout -b somename origin/somename

[/pastacode]

That’s it… the branch will be set up to track the remote and you are switched over automatically.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.