How to push a new git branch to remote and track immediately

Learn how to create a new git branch based off a local one, push it to remote and set up tracking information at the same time.

I’d be pretty rich if I had £1 for everytime I’ve looked this up. So in the interests of my future self and anyone else who may be wondering, here’s the solution.

# In the branch you want to branch off
# Create the branch
$ git checkout -b my_new_feature
# Push and set up tracking information
$ git push -u origin my_new_feature
comments powered by Disqus