HomeContact
Git
How to change the remote branch tracked using git
July 20, 2020
1 min

When you use git and create a local branch:

git checkout -b branch_name

And push all your work using git push. Usually you will be prompted from git to define the remote name for the tracking of this branch (normally you use the same name branch_name) :

git push --set-upstream origin branch_name

This will push your branch to a remote branch called branch_name on your git server.

Though in some case you need to change the remote branch followed in order to push some work :

  • Using git v1.8.0 or later:

    git branch branch_name --set-upstream-to your_new_remote/branch_name

  • Or you can use the -u switch:

    git branch branch_name -u your_new_remote/branch_name

  • Using git v1.7.12 or earlier:

    git branch --set-upstream branch_name your_new_remote/branch_name


Related Posts

How to remove or change remote origin from a Git repository
September 19, 2023
1 min
© 2023, All Rights Reserved.

Quick Links

Contact Us

Social Media