How do I push a new local branch to a remote Git repository and track it too?

Created by Daniel RuosoLinked to 54.5m issues across 64 teams

tl;dr

Step 1 - Create a new branch:

git checkout -b <branch>

Step 2 - Make changes to the files, add and commit them.

Step 3 - Push the branch to the remote repository with the -u option:

git push -u origin <branch>

This will set up the tracking information for the branch.