As I’ve been pairing recently, my pair created a branch that we can work on. As we added more and more code to the branch, which we pushed to Github, I wanted to check it out locally so I can play around with it and push any necessary changes that I made.
But I had a hard time finding how to do that. Here is how to actually checkout a remote Github branch locally (so you can pull the changes, not just clone the branch):
$ git checkout -b branch_name origin/branch_name
You can use the track option to track the remote branch locally. Once you’re tracking it, you can check it out and work on it:
git checkout -t branch_name origin/branch_name