# git push --no-mirror ?

3 messages from 2010-03-08 to 2010-03-09. Participants: SZEDER Gábor, Junio C Hamano.
Thread: https://gitlist.dev/t/22950

## SZEDER Gábor, 2010-03-08 12:34

Subject: git push --no-mirror ?
Message-ID: <20100308123423.GA20486@neumann>
URL: https://gitlist.dev/e/20100308123423.GA20486%40neumann

```
Hi,


I have a remote that I use mainly for backup with 'mirror = true' in
gitconfig, but also for sharing my "bleeding-edge" code with a
student.  Now I came across the situation where I would liked to push
only a single branch to that repo, only to discover that 'git push'
has no '--no-mirror' option to override the related configuration
setting.  Removing the 'mirror = true' line from the config, doing the
push, restoring the config did the trick, of course, but I think there
should be a simpler way to do that.  Is there a fundamental reason why
there is no 'push --no-mirror', or just noone has noticed/bothered
before?


Thanks,
Gábor

```

## Junio C Hamano, 2010-03-08 20:49

Subject: Re: git push --no-mirror ?
Message-ID: <7vzl2ipmhn.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vzl2ipmhn.fsf%40alter.siamese.dyndns.org
In-Reply-To: <20100308123423.GA20486@neumann>

```
SZEDER Gábor <szeder@ira.uka.de> writes:

> I have a remote that I use mainly for backup with 'mirror = true' in
> gitconfig, but also for sharing my "bleeding-edge" code with a
> student.  Now I came across the situation where I would liked to push
> only a single branch to that repo, only to discover that 'git push'
> has no '--no-mirror' option to override the related configuration
> setting.  Removing the 'mirror = true' line from the config, doing the
> push, restoring the config did the trick, of course, but I think there
> should be a simpler way to do that.  Is there a fundamental reason why
> there is no 'push --no-mirror', or just noone has noticed/bothered
> before?

I think that is the case.  How does this look (haven't thought it through
nor even compile tested yet)?

 builtin-push.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/builtin-push.c b/builtin-push.c
index f7bc2b2..89df1ff 100644
--- a/builtin-push.c
+++ b/builtin-push.c
@@ -145,7 +145,7 @@ static int do_push(const char *repo, int flags)
 		die("No destination configured to push to.");
 	}
 
-	if (remote->mirror)
+	if (!refspec && remote->mirror)
 		flags |= (TRANSPORT_PUSH_MIRROR|TRANSPORT_PUSH_FORCE);
 
 	if ((flags & TRANSPORT_PUSH_ALL) && refspec) {

```

## SZEDER Gábor, 2010-03-09 12:04

Subject: Re: git push --no-mirror ?
Message-ID: <20100309120428.GE4748@neumann>
URL: https://gitlist.dev/e/20100309120428.GE4748%40neumann
In-Reply-To: <7vzl2ipmhn.fsf@alter.siamese.dyndns.org>

```
Hi,


On Mon, Mar 08, 2010 at 12:49:40PM -0800, Junio C Hamano wrote:
> SZEDER Gábor <szeder@ira.uka.de> writes:
> 
> > I have a remote that I use mainly for backup with 'mirror = true' in
> > gitconfig, but also for sharing my "bleeding-edge" code with a
> > student.  Now I came across the situation where I would liked to push
> > only a single branch to that repo, only to discover that 'git push'
> > has no '--no-mirror' option to override the related configuration
> > setting.  Removing the 'mirror = true' line from the config, doing the
> > push, restoring the config did the trick, of course, but I think there
> > should be a simpler way to do that.  Is there a fundamental reason why
> > there is no 'push --no-mirror', or just noone has noticed/bothered
> > before?
> 
> I think that is the case.  How does this look (haven't thought it through
> nor even compile tested yet)?
> 
>  builtin-push.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/builtin-push.c b/builtin-push.c
> index f7bc2b2..89df1ff 100644
> --- a/builtin-push.c
> +++ b/builtin-push.c
> @@ -145,7 +145,7 @@ static int do_push(const char *repo, int flags)
>  		die("No destination configured to push to.");
>  	}
>  
> -	if (remote->mirror)
> +	if (!refspec && remote->mirror)
>  		flags |= (TRANSPORT_PUSH_MIRROR|TRANSPORT_PUSH_FORCE);
>  
>  	if ((flags & TRANSPORT_PUSH_ALL) && refspec) {

thanks, this DWIMery seems to work just fine (i.e. solves my problem
and does not break any tests in the test suite).


Best,
Gábor

```
