Can't rename remote branch
I want to rename a remote branch from research_mvp to research
I first renamed the local branch
[research_mvp]> git branch -m research_mvp research
Second, I delete the remote branch
[research]> git push origin :research_mvp
Third, I push a new branch
[research]> git push --set-upstream origin research
This makes a new remote branch with the old remote branch name.
* [new branch] research -> research_mvp
Why is it using the name of the old branch instead of the name of the new branch I pushed?
source to share
Since you renamed the branch, you keep the link to the remote branch to push. When you did git push --set-upstream origin reference
, it didn't change the remote in the file .git/config
. Part of the problem is probably that git still thinks it origin/research_mvp
still exists.
You may be able to fix it by running git fetch --prune
. git will update to understand that it origin/research_mvp
no longer exists. It does not delete this relationship when deleting a remote branch. Then the launch git push --set-upstream origin reference
should work correctly.
Another option is to create a new branch and make a new click.
git checkout research
git branch -m research research_temp
git checkout research_temp
git checkout -b research
git branch -d research_temp
git push -u origin research
source to share