Git branch -m and remote tracking branches

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 newbranch to origin and update the upstream info. If you want to be really explicit, you can use git 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 your oldbranch will see the branch get deleted, and anyone who blindly pushes their copy of oldbranch may inadvertently re-create the branch on the server.

While there probably are git plumbing command to rename the upstream and the local branches, I wouldn't really bother much about it.

A workflow that is simple is to create a new branch from the branch-you-want-renamed with the new-name-you-want, and then go about deleting the old branch and then you push the branch, it goes with your new-name

git checkout oldname
git branch newbranch
git branch -d oldname
git push newbranch

Because a branch is identified by it's name, old users who may be tracking this earlier branch will be affected and some may, if they have corresponding permissions, end up creating a branch with that name.

Need Your Help

AZIMUTH reading too sensitive on Sony Xperia phone updated with android OS 4.3 even with low pass filter

android android-sensors

I am troubled with the too sensitive sensor reading issue with SONY Xperia phone loaded with android OS 4.3 .

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.