Re: checkout new branch tracks wrong remote (bug?)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Mar 30, 2011 at 02:27:31AM +0000, chris wrote:

> I have two remotes configured.
> 
> One is "origin" which has a local tracking branch "master" for "origin/master".
> 
> The other is "mirror" which has option mirror = true
> 
> While on the local branch master, I issue the command:
> 
> $ git checkout -b wip
> 
> The branch "wip" is created and oddly configured to track the "mirror" remote.

Right. You are creating a branch from "refs/heads/master" (the currently
checked out branch). So the setup_tracking code will look for any remote
which writes a tracking branch into refs/heads/master according to the
configuration.

Your mirror config looks like this:

> [remote "mirror"]
>         url = ssh://chris@xxxxxxxxxxxx/srv/git/mirrors/chris/myproject.git
>         fetch = +refs/*:refs/*
>         mirror = true

meaning that a fetch of the mirror remote will write the mirror's
refs/heads/master into our local refs/heads/master. IOW, your master
branch is actually configured as a remote tracking branch of the mirror
(which is probably not what you want; see below).

> I do not expect this "wip" branch to be tracking the "mirror" remote, but rather
> "origin", according to the documentation.

In the absence of the mirror remote, it would not track anything. You
are branching from a _local_ branch, so there is no remote to track. I
think what you really want is:

  git checkout -b wip origin/master

All of that being said, I'm not sure your config makes sense:

> [remote "origin"]
>         fetch = +refs/heads/*:refs/remotes/origin/*
>         url = ssh://myserver.com/srv/git/myproject.git
> [remote "mirror"]
>         url = ssh://chris@xxxxxxxxxxxx/srv/git/mirrors/chris/myproject.git
>         fetch = +refs/*:refs/*
>         mirror = true

Your mirror is configured to overwrite everything in refs/ if you fetch
from it. Meaning it will throw away anything you fetched from "origin",
as well as any local work. So this config is probably not what you want.

I'm guessing what you really wanted is a remote only for pushing to, and
created it with:

  git remote add --mirror mirror ssh://...

The --mirror option has problems with that case. See this thread:

  http://article.gmane.org/gmane.comp.version-control.git/161653

which has some suggestions, but nothing has been implemented yet.
Probably it makes sense to allow --mirror=fetch and --mirror=push, but
there is an open question of what just "--mirror" should do.

-Peff
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]