I just renamed my local branch using
git branch -m oldname newname
but this only renames the local version of the branch. How can I rename the one on GitHub?
branchgitgithubrename
I just renamed my local branch using
git branch -m oldname newname
but this only renames the local version of the branch. How can I rename the one on GitHub?
Best Answer
As mentioned, delete the old one on GitHub and re-push, though the commands used are a bit more verbose than necessary:
Dissecting the commands a bit, the
git push
command is essentially:So doing a push with no local_branch specified essentially means "take nothing from my local repository, and make it the remote branch". I've always thought this to be completely kludgy, but it's the way it's done.
As of Git 1.7 there is an alternate syntax for deleting a remote branch:
As mentioned by @void.pointer in the comments
This can be turned into a simple alias that takes the remote, original branch and new branch name as arguments, in
~/.gitconfig
:Usage:
Note that positional arguments in shell commands were problematic in older (pre 2.8?) versions of Git, so the alias might vary according to the Git version. See this discussion for details.