I have a branch I’ve already pushed to github using –set-upstream. I want to rename it now, and have that change reflected on github. Here’s what I want to do
git branch -m oldbranch newbranch
git push origin :oldbranch
git push --set-upstream newbranch
Running ‘branch -m’ doesn’t update my .git/config apart from changing the branch to ‘newbranch’. branch.newbranch.merge is still ‘refs/heads/oldbranch’. When I push if I issue the command
git push --set-upstream origin newbranch
is that going to properly update my .git/config? Any potential impact on other users? No one else is currently committing to the branch, and I don’t think anyone’s even checked it out.
Yes, that should push
newbranchtooriginand update the upstream info. If you want to be really explicit, you can usegit push --set-upstream origin newbranch:newbranch.As for impacting other users, you’re proposing to delete the original branch (
oldbranch) and create a new branch (newbranch). They just happen to have the same names. However, other users won’t “magically” get the branch name change. Anyone who’s following youroldbranchwill see the branch get deleted, and anyone who blindly pushes their copy ofoldbranchmay inadvertently re-create the branch on the server.