If there is a repository that I only have git:// access to (and would usually just push+pull), is there a way to rename branches in that repository in the same
If you really just want to rename branches remotely, without renaming any local branches at the same time, you can do this with a single command:
git push /:refs/heads/ :
I wrote this script (git-rename-remote-branch) which provides a handy shortcut to do the above easily.
As a bash function:
git-rename-remote-branch(){
if [ $# -ne 3 ]; then
echo "Rationale : Rename a branch on the server without checking it out."
echo "Usage : ${FUNCNAME[0]} "
echo "Example : ${FUNCNAME[0]} origin master release"
return 1
fi
git push $1 $1/$2\:refs/heads/$3 :$2
}
To integrate @ksrb's comment: What this basically does is two pushes in a single command, first git push to push a new remote branch based on the old remote tracking branch and then git push to delete the old remote branch.