threads / bug / 13866

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

Subject: [BUG] git-branch -m cannot rename remote branches

## tl;dr

4 messages between Jun 8, 2008 and Jun 9, 2008.

replies: 3people: 3as markdown or json

Jakub Narebski· Jun 8, 2008, 20:57 UTC · lore

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· Jun 8, 2008, 22:58 UTC · re: Jakub Narebski · lore

Re: [BUG] git-branch -m cannot rename remote branches

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· Jun 9, 2008, 07:06 UTC · re: Johannes Schindelin · lore

Re: [BUG] git-branch -m cannot rename remote branches

On Mon, 9 Jun 2008, Johannes Schindelin wrote:
Show 10 quoted lines
> 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· Jun 9, 2008, 12:53 UTC · re: Jakub Narebski · lore

Re: [BUG] git-branch -m cannot rename remote branches

Jakub Narebski a écrit :
Show 11 quoted lines
> 
> 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.

← back to recent threads