git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* moving a remote branch?
@ 2010-06-17  4:35 Thomas Anderson
  2010-06-17  6:19 ` Nazri Ramliy
  0 siblings, 1 reply; 8+ messages in thread
From: Thomas Anderson @ 2010-06-17  4:35 UTC (permalink / raw)
  To: git

git branch -m origin/zelnaga/featurea origin/zelnaga/featureb doesn't
seem to be working for me.  Instead, I get this error:l

error: refname refs/heads/origin/zelnaga/featurea
fatal: Branch rename failed

Any ideas?

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: moving a remote branch?
  2010-06-17  4:35 moving a remote branch? Thomas Anderson
@ 2010-06-17  6:19 ` Nazri Ramliy
  2010-06-17  8:28   ` Peter Kjellerstedt
  0 siblings, 1 reply; 8+ messages in thread
From: Nazri Ramliy @ 2010-06-17  6:19 UTC (permalink / raw)
  To: Thomas Anderson; +Cc: git

On Thu, Jun 17, 2010 at 12:35 PM, Thomas Anderson <zelnaga@gmail.com> wrote:
> git branch -m origin/zelnaga/featurea origin/zelnaga/featureb doesn't
> seem to be working for me.  Instead, I get this error:l
>
> error: refname refs/heads/origin/zelnaga/featurea
> fatal: Branch rename failed
>
> Any ideas?

The error  message could be improved here.

The reason you get the error is because you were asking git
to rename a "remote" branch, which it refuses to do because,
well, it's a remote branch, and for all practical purposes git
won't allow you to modify any "remote" stuff as they are all
read-only from our point of view.

If you run "git remote -v" you'll most likely see that "origin"
is listed in the output which means that your "origin/zelnaga/featurea"
is a remote branch because its name begin with "origin/".

Hope this helps.

nazri.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: moving a remote branch?
  2010-06-17  6:19 ` Nazri Ramliy
@ 2010-06-17  8:28   ` Peter Kjellerstedt
  2010-06-17 12:13     ` Nazri Ramliy
  2010-06-17 13:55     ` Thomas Anderson
  0 siblings, 2 replies; 8+ messages in thread
From: Peter Kjellerstedt @ 2010-06-17  8:28 UTC (permalink / raw)
  To: Nazri Ramliy, Thomas Anderson; +Cc: git@vger.kernel.org

> -----Original Message-----
> From: git-owner@vger.kernel.org [mailto:git-owner@vger.kernel.org] On
> Behalf Of Nazri Ramliy
> Sent: den 17 juni 2010 08:20
> To: Thomas Anderson
> Cc: git@vger.kernel.org
> Subject: Re: moving a remote branch?
> 
> On Thu, Jun 17, 2010 at 12:35 PM, Thomas Anderson <zelnaga@gmail.com>
> wrote:
> > git branch -m origin/zelnaga/featurea origin/zelnaga/featureb doesn't
> > seem to be working for me.  Instead, I get this error:l
> >
> > error: refname refs/heads/origin/zelnaga/featurea
> > fatal: Branch rename failed
> >
> > Any ideas?
> 
> The error  message could be improved here.
> 
> The reason you get the error is because you were asking git
> to rename a "remote" branch, which it refuses to do because,
> well, it's a remote branch, and for all practical purposes git
> won't allow you to modify any "remote" stuff as they are all
> read-only from our point of view.
> 
> If you run "git remote -v" you'll most likely see that "origin"
> is listed in the output which means that your "origin/zelnaga/featurea"
> is a remote branch because its name begin with "origin/".
> 
> Hope this helps.
> 
> nazri.

Renaming a remote branch is a two step operation. First you push the 
old branch into its new name, and then you remove the old branch. It 
can be done with these commands:

	git push origin origin/featurea:refs/heads/featureb
	git push origin :featurea

//Peter

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: moving a remote branch?
  2010-06-17  8:28   ` Peter Kjellerstedt
@ 2010-06-17 12:13     ` Nazri Ramliy
  2010-06-17 13:02       ` Peter Kjellerstedt
  2010-06-17 13:55     ` Thomas Anderson
  1 sibling, 1 reply; 8+ messages in thread
From: Nazri Ramliy @ 2010-06-17 12:13 UTC (permalink / raw)
  To: Peter Kjellerstedt; +Cc: Thomas Anderson, git@vger.kernel.org

On Thu, Jun 17, 2010 at 4:28 PM, Peter Kjellerstedt > Renaming a
remote branch is a two step operation. First you push the
> old branch into its new name, and then you remove the old branch. It
> can be done with these commands:
>
>        git push origin origin/featurea:refs/heads/featureb
>        git push origin :featurea

I'd like to add (more confusion!:) with this clarification:

The two push operation above rename the branch on the remote side.
It does not affect any of your local branches.

If you do "git branch -a" then you'd still see the
"origin/zelnaga/featurea" branch.

Doing a "git fetch origin" will get the newly renamed branch from the
remote repo and create a local version of it on your local repo.

At this point you can do "git branch -D origin/featurea".

nazri

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: moving a remote branch?
  2010-06-17 12:13     ` Nazri Ramliy
@ 2010-06-17 13:02       ` Peter Kjellerstedt
  2010-06-17 13:19         ` Nazri Ramliy
  0 siblings, 1 reply; 8+ messages in thread
From: Peter Kjellerstedt @ 2010-06-17 13:02 UTC (permalink / raw)
  To: Nazri Ramliy; +Cc: Thomas Anderson, git@vger.kernel.org

> -----Original Message-----
> From: git-owner@vger.kernel.org [mailto:git-owner@vger.kernel.org] On
> Behalf Of Nazri Ramliy
> Sent: den 17 juni 2010 14:13
> To: Peter Kjellerstedt
> Cc: Thomas Anderson; git@vger.kernel.org
> Subject: Re: moving a remote branch?
> 
> On Thu, Jun 17, 2010 at 4:28 PM, Peter Kjellerstedt 
> > Renaming a remote branch is a two step operation. First you push the
> > old branch into its new name, and then you remove the old branch. It
> > can be done with these commands:
> >
> >        git push origin origin/featurea:refs/heads/featureb
> >        git push origin :featurea
> 
> I'd like to add (more confusion!:) with this clarification:
> 
> The two push operation above rename the branch on the remote side.
> It does not affect any of your local branches.

No, it does not affect any local branches, but it _does_ effect 
the representation of the remote branches in the local repository.

> If you do "git branch -a" then you'd still see the
> "origin/zelnaga/featurea" branch.

No, you will not (at least not with git 1.7.1 that I use). 

Neither do you need to do the two steps below as the two pushes 
above are enough to also keep the status of the remote branches 
in sync in the local repository..

> Doing a "git fetch origin" will get the newly renamed branch from the
> remote repo and create a local version of it on your local repo.
> 
> At this point you can do "git branch -D origin/featurea".
> 
> nazri

//Peter

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: moving a remote branch?
  2010-06-17 13:02       ` Peter Kjellerstedt
@ 2010-06-17 13:19         ` Nazri Ramliy
  0 siblings, 0 replies; 8+ messages in thread
From: Nazri Ramliy @ 2010-06-17 13:19 UTC (permalink / raw)
  To: Peter Kjellerstedt; +Cc: Thomas Anderson, git@vger.kernel.org

On Thu, Jun 17, 2010 at 9:02 PM, Peter Kjellerstedt >
> No, you will not (at least not with git 1.7.1 that I use).
>
> Neither do you need to do the two steps below as the two pushes
> above are enough to also keep the status of the remote branches
> in sync in the local repository..
>
> //Peter

Ah, you are right. Thanks for the lesson.

nazri.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: moving a remote branch?
  2010-06-17  8:28   ` Peter Kjellerstedt
  2010-06-17 12:13     ` Nazri Ramliy
@ 2010-06-17 13:55     ` Thomas Anderson
  2010-06-17 15:05       ` Peter Kjellerstedt
  1 sibling, 1 reply; 8+ messages in thread
From: Thomas Anderson @ 2010-06-17 13:55 UTC (permalink / raw)
  To: Peter Kjellerstedt; +Cc: Nazri Ramliy, git@vger.kernel.org

Do I need to switch to the local featurea branch before doing "git
push origin origin/featurea:refs/heads/featureb" or can I do that
while in the default branch?

On Thu, Jun 17, 2010 at 3:28 AM, Peter Kjellerstedt
<peter.kjellerstedt@axis.com> wrote:
>> -----Original Message-----
>> From: git-owner@vger.kernel.org [mailto:git-owner@vger.kernel.org] On
>> Behalf Of Nazri Ramliy
>> Sent: den 17 juni 2010 08:20
>> To: Thomas Anderson
>> Cc: git@vger.kernel.org
>> Subject: Re: moving a remote branch?
>>
>> On Thu, Jun 17, 2010 at 12:35 PM, Thomas Anderson <zelnaga@gmail.com>
>> wrote:
>> > git branch -m origin/zelnaga/featurea origin/zelnaga/featureb doesn't
>> > seem to be working for me.  Instead, I get this error:l
>> >
>> > error: refname refs/heads/origin/zelnaga/featurea
>> > fatal: Branch rename failed
>> >
>> > Any ideas?
>>
>> The error  message could be improved here.
>>
>> The reason you get the error is because you were asking git
>> to rename a "remote" branch, which it refuses to do because,
>> well, it's a remote branch, and for all practical purposes git
>> won't allow you to modify any "remote" stuff as they are all
>> read-only from our point of view.
>>
>> If you run "git remote -v" you'll most likely see that "origin"
>> is listed in the output which means that your "origin/zelnaga/featurea"
>> is a remote branch because its name begin with "origin/".
>>
>> Hope this helps.
>>
>> nazri.
>
> Renaming a remote branch is a two step operation. First you push the
> old branch into its new name, and then you remove the old branch. It
> can be done with these commands:
>
>        git push origin origin/featurea:refs/heads/featureb
>        git push origin :featurea
>
> //Peter
>
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: moving a remote branch?
  2010-06-17 13:55     ` Thomas Anderson
@ 2010-06-17 15:05       ` Peter Kjellerstedt
  0 siblings, 0 replies; 8+ messages in thread
From: Peter Kjellerstedt @ 2010-06-17 15:05 UTC (permalink / raw)
  To: Thomas Anderson; +Cc: Nazri Ramliy, git@vger.kernel.org

> -----Original Message-----
> From: git-owner@vger.kernel.org [mailto:git-owner@vger.kernel.org] On
> Behalf Of Thomas Anderson
> Sent: den 17 juni 2010 15:56
> To: Peter Kjellerstedt
> Cc: Nazri Ramliy; git@vger.kernel.org
> Subject: Re: moving a remote branch?
> 
> Do I need to switch to the local featurea branch before doing "git
> push origin origin/featurea:refs/heads/featureb" or can I do that
> while in the default branch?

You do not need to switch branch. The command above has all
the information it needs on the command line.

One thing to note though. If you have a local branch tracking
the remote featurea branch, it will not automatically start
tracking the featureb branch when you rename the remote branch.
You will have to fix the tracking manually (either by setting
up a new tracking branch for featureb, or by editing the
.git/config file to reflect the new situation).

//Peter

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2010-06-17 15:05 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-17  4:35 moving a remote branch? Thomas Anderson
2010-06-17  6:19 ` Nazri Ramliy
2010-06-17  8:28   ` Peter Kjellerstedt
2010-06-17 12:13     ` Nazri Ramliy
2010-06-17 13:02       ` Peter Kjellerstedt
2010-06-17 13:19         ` Nazri Ramliy
2010-06-17 13:55     ` Thomas Anderson
2010-06-17 15:05       ` Peter Kjellerstedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).