I want to be able to do the following:
Create a local branch based on some other (remote or local) branch (via git branch
or git checkout
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
and git push
will work immediately
git 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-upstream
. This will add an upstream tracking reference for the current branch. you can verify this by looking in your .git/config file: