A slight variation of the solutions already given here:
Create a local branch based on some other (remote or local) branch:
git checkout -b branchname
Push the local branch to the remote repository (publish), but make it trackable so
git pull
andgit push
will work immediatelygit push -u origin HEAD
Using
HEAD
is a "handy way to push the current branch to the same name on the remote". Source: https://git-scm.com/docs/git-push In Git terms, HEAD (in uppercase) is a reference to the top of the current branch (tree).The
-u
option is just short for--set-setupstreamupstream
. This will add an upstream tracking reference for the current branch. you can verify this by looking in your .git/config file: