Git allows you to associate local branches to remote branches (this is called tracking), and tracking a branch which already exists in the remote repository is super easy:
git branch --track branch_name repo/branch_name
But what do you do if you created the branch locally, then pushed to the remote repo?
git branch -f branch_name repo/branch_name
Note: You can’t execute that command while you’re currently in the branch you want to track. IE -
git checkout to another branch first.
“Why?” you might ask. If you have branch tracking set up, you can leave off the last two arguments from
git push and
git push repo branch_name