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?
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?
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.
RE: moving a remote branch?
> -----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
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.
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
RE: moving a remote branch?
> -----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
Re: moving a remote branch?
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.
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?
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 > >
RE: moving a remote branch?
> -----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