The central
repository had to be set up on a new server, so I created a new remote on my local repo, and pushed to that.
But now when I do git pull
, it claims I am up to date. It's wrong—it's telling me about the old remote branch, not the new one, which I know for a fact has new commits to fetch.
How do I change my local branch to track a different remote?
I can see this in the git config file but I don't want to mess things up.
[branch "master"] remote = oldserver merge = refs/heads/master
Simply delete your remote tracking branch: git branch -d -r origin/<remote branch name> (This will not delete the branch on the remote repo!) That will make any push/pull completely unaware of origin/.
There is a command that gives you about all tracking branches. And to know about the pull and push configuration per branch you can use the command git remote show origin. and you can use -sb option for seeing the upstream. Hope this information will help you to find which branch is tracking.
The easiest way to set the upstream branch is to use the “git push” command with the “-u” option for upstream branch. Alternatively, you can use the “–set-upstream” option that is equivalent to the “-u” option. As an example, let's say that you created a branch named “branch” using the checkout command.
git branch branch_name --set-upstream-to your_new_remote/branch_name
-u
switchgit branch branch_name -u your_new_remote/branch_name
git branch --set-upstream branch_name your_new_remote/branch_name
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With