# [BUG] git-branch -m cannot rename remote branches

4 messages from 2008-06-08 to 2008-06-09. Participants: Jakub Narebski, Johannes Schindelin, Olivier Marin.
Thread: https://gitlist.dev/t/13866

## Jakub Narebski, 2008-06-08 20:57

Subject: [BUG] git-branch -m cannot rename remote branches
Message-ID: <200806082257.20833.jnareb@gmail.com>
URL: https://gitlist.dev/e/200806082257.20833.jnareb%40gmail.com

```
I cannot rename remote branch (possibly packed, and possibly with
reflog) using "git branch"

[gitweb/web@git]$ git branch -m refs/remotes/gitweb-caching/master \
                                refs/remotes/gitweb-kernel.org/master
error: refname refs/heads/refs/remotes/gitweb-caching/master not found
fatal: Branch rename failed
[gitweb/web@git]$ git branch -m gitweb-caching/master \
                                gitweb-kernel.org/master
error: refname refs/heads/gitweb-caching/master not found
fatal: Branch rename failed
[gitweb/web@git]$ git branch -m remotes/gitweb-caching/master \
                                remotes/gitweb-kernel.org/master
error: refname refs/heads/remotes/gitweb-caching/master not found
fatal: Branch rename failed

-- 
Jakub Narebski
Poland

```

## Johannes Schindelin, 2008-06-08 22:58

Subject: Re: [BUG] git-branch -m cannot rename remote branches
Message-ID: <alpine.DEB.1.00.0806082357470.1783@racer>
URL: https://gitlist.dev/e/alpine.DEB.1.00.0806082357470.1783%40racer
In-Reply-To: <200806082257.20833.jnareb@gmail.com>

```
Hi,

On Sun, 8 Jun 2008, Jakub Narebski wrote:

> I cannot rename remote branch (possibly packed, and possibly with
> reflog) using "git branch"

That is very much by design; a next fetch would get them with their 
current name anyway.  A "remote prune" should get rid of any stale 
branches.

So yes, "branch -m" with remote branches does not make sense.

Ciao,
Dscho

```

## Jakub Narebski, 2008-06-09 07:06

Subject: Re: [BUG] git-branch -m cannot rename remote branches
Message-ID: <200806090906.51937.jnareb@gmail.com>
URL: https://gitlist.dev/e/200806090906.51937.jnareb%40gmail.com
In-Reply-To: <alpine.DEB.1.00.0806082357470.1783@racer>

```
On Mon, 9 Jun 2008, Johannes Schindelin wrote:
> On Sun, 8 Jun 2008, Jakub Narebski wrote:
> 
> > I cannot rename remote branch (possibly packed, and possibly with
> > reflog) using "git branch"
> 
> That is very much by design; a next fetch would get them with their 
> current name anyway.  A "remote prune" should get rid of any stale 
> branches.
> 
> So yes, "branch -m" with remote branches does not make sense.

What I really wanted was "git remote rename <old-name> <new-name>",
together with renaming branches and moving reflogs.  I can do first
part by editing config file ("git remote rename"/"git remote mv"
probably would want to assume that user wants to move branches if
they follow remotes/<old-name>/* calling convention; ask user if it
is not the case?).  I thought that I could use "git branch -m" for
the other... I was left with editing packed-refs file (BTW. is leaving
empty directory 'xx' when packing 'xx/name' branch by design?) and
moving reflog by hand.

-- 
Jakub Narebski
Poland

```

## Olivier Marin, 2008-06-09 12:53

Subject: Re: [BUG] git-branch -m cannot rename remote branches
Message-ID: <484D27C9.4000102@free.fr>
URL: https://gitlist.dev/e/484D27C9.4000102%40free.fr
In-Reply-To: <200806090906.51937.jnareb@gmail.com>

```
Jakub Narebski a écrit :
> 
> What I really wanted was "git remote rename <old-name> <new-name>",
> together with renaming branches and moving reflogs.  I can do first
> part by editing config file ("git remote rename"/"git remote mv"
> probably would want to assume that user wants to move branches if
> they follow remotes/<old-name>/* calling convention; ask user if it
> is not the case?).  I thought that I could use "git branch -m" for
> the other... I was left with editing packed-refs file (BTW. is leaving
> empty directory 'xx' when packing 'xx/name' branch by design?) and
> moving reflog by hand.
> 

You can use "git update-ref" for that. Maybe something like that:

$ git update-ref <newref> <oldref>
$ git update-ref -d <oldref> <newref>

Olivier.

```
