Push a new branch up to GitHub (if it doesn’t exist there yet)

Say you’ve created a new branch called new-feature on one computer and this branch and its new code has not yet been pushed up to GitHub. This is how you do that:

git push -u origin new-feature

This will establish the new-feature on the GitHub repository.

It also means that now, going forward, when your local computer is on the new-feature branch and then you do git push, then you will be pushing to the new-feature branch on GitHub (in other words, no need to add -u origin new-feature every time you want to push to this branch).

Last updated