**Create a new branch:**
`git checkout -b <new branch name>`
Push a new branch and track it immediately
When you create a new branch and push it to `origin`, you won’t be tracking it. This means a `git pull` won’t know its remote version.
You could use difficult commands to set up a branch’s tracking but it’s easier to just push it like this:
`git push -u`
From the [documentation on git push](http://linux.die.net/man/1/git-push):
`-u, --set-upstream`
*e.g.*
`git push origin --set-upstream <branch_name>`
*For every branch that is up to date or successfully pushed, add upstream (tracking) reference, used by argument-less git-pull(1) and other commands. For more information, see branch..merge in git-config(1).*
---
**Set an existing branch to track a remote branch**
If you already have a local branch and want to set it to a remote branch you just pulled down, or want to change the upstream branch you’re tracking, you can use the `-u` or `--set-upstream-to` option to `git branch` to explicitly set it at any time.
`git branch -u origin/serverfix`
Branch serverfix set up to track remote branch serverfix from origin.