# How to ignore changes on remote

14 messages from 2010-03-23 to 2010-03-23. Participants: Howard Miller, Sylvain Rabot, Santi Béjar, Alexander Iljin, Scott Chacon, Johannes Sixt, Junio C Hamano, Johan Herland, Jakub Narebski.
Thread: https://gitlist.dev/t/23150

## Howard Miller, 2010-03-23 13:54

Subject: How to ignore changes on remote
Message-ID: <26ae428a1003230654m50c35caci4a02e2df321f289c@mail.gmail.com>
URL: https://gitlist.dev/e/26ae428a1003230654m50c35caci4a02e2df321f289c%40mail.gmail.com

```
My remote branch has changes that are not fast forward (I forgot to
merge). I have now made incompatible changes on my local branch. I
simply want to use the local version and push it to the remote. I
don't care about the remote version. I don't want to merge as there'll
be loads of conflicts and the answer will always be 'use the local
one'. Is there an easy way to do this? I can't think of anything.

Cheers!

```

## Sylvain Rabot, 2010-03-23 14:07

Subject: Re: How to ignore changes on remote
Message-ID: <1269353235.14299.0.camel@kheops>
URL: https://gitlist.dev/e/1269353235.14299.0.camel%40kheops
In-Reply-To: <26ae428a1003230654m50c35caci4a02e2df321f289c@mail.gmail.com>

```
On Tue, 2010-03-23 at 13:54 +0000, Howard Miller wrote:
> My remote branch has changes that are not fast forward (I forgot to
> merge). I have now made incompatible changes on my local branch. I
> simply want to use the local version and push it to the remote. I
> don't care about the remote version. I don't want to merge as there'll
> be loads of conflicts and the answer will always be 'use the local
> one'. Is there an easy way to do this? I can't think of anything.
> 
> Cheers!

git push origin +local_branch:remote_branch

-- 
Sylvain Rabot <sylvain@abstraction.fr>

```

## Howard Miller, 2010-03-23 14:13

Subject: Re: How to ignore changes on remote
Message-ID: <26ae428a1003230713y12f0c74dh3b22c0d97565159b@mail.gmail.com>
URL: https://gitlist.dev/e/26ae428a1003230713y12f0c74dh3b22c0d97565159b%40mail.gmail.com
In-Reply-To: <1269353235.14299.0.camel@kheops>

```
>
> git push origin +local_branch:remote_branch
>

Thanks!

Tell me more about that '+'. I've never heard of it before. Can't see
anything in the docs (although I'm probably not looking in the right
place)

```

## Alexander Iljin, 2010-03-23 14:21

Subject: Re: How to ignore changes on remote
Message-ID: <465338777.20100323202112@yandex.ru>
URL: https://gitlist.dev/e/465338777.20100323202112%40yandex.ru
In-Reply-To: <26ae428a1003230713y12f0c74dh3b22c0d97565159b@mail.gmail.com>

```
Hello!

>>
>> git push origin +local_branch:remote_branch
>>

HM> Tell me more about that '+'. I've never heard of it before. Can't see
HM> anything in the docs (although I'm probably not looking in the right
HM> place)

  git help push

<refspec>…
  The format of a <refspec> parameter is an optional plus +, followed
  by the source ref <src>, followed by a colon :, followed by the
  destination ref <dst>. It is used to specify with what <src> object
  the <dst> ref in the remote repository is to be updated.

  ...

  By having the optional leading +, you can tell git to update the
  <dst> ref even when the update is not a fast forward. This does not
  attempt to merge <src> into <dst>. See EXAMPLES below for details.

---=====---
 Alexander

```

## Santi Béjar, 2010-03-23 14:22

Subject: Re: How to ignore changes on remote
Message-ID: <adf1fd3d1003230722t338c140an527b77f4023c9729@mail.gmail.com>
URL: https://gitlist.dev/e/adf1fd3d1003230722t338c140an527b77f4023c9729%40mail.gmail.com
In-Reply-To: <26ae428a1003230713y12f0c74dh3b22c0d97565159b@mail.gmail.com>

```
On Tue, Mar 23, 2010 at 3:13 PM, Howard Miller
<howardsmiller@googlemail.com> wrote:
>>
>> git push origin +local_branch:remote_branch
>>
>
> Thanks!
>
> Tell me more about that '+'. I've never heard of it before. Can't see
> anything in the docs (although I'm probably not looking in the right
> place)

man git-push and search for '+', there is even an example like the
command above.

HTH,
Santi

```

## Howard Miller, 2010-03-23 14:24

Subject: Re: How to ignore changes on remote
Message-ID: <26ae428a1003230724o6b901e0s7d789f63d4718827@mail.gmail.com>
URL: https://gitlist.dev/e/26ae428a1003230724o6b901e0s7d789f63d4718827%40mail.gmail.com
In-Reply-To: <adf1fd3d1003230722t338c140an527b77f4023c9729@mail.gmail.com>

```
>
> man git-push and search for '+', there is even an example like the
> command above.
>

Not on my docs (1.5.4) but it works anyway. Thanks!

```

## Sylvain Rabot, 2010-03-23 14:25

Subject: Re: How to ignore changes on remote
Message-ID: <1269354326.14299.7.camel@kheops>
URL: https://gitlist.dev/e/1269354326.14299.7.camel%40kheops
In-Reply-To: <26ae428a1003230713y12f0c74dh3b22c0d97565159b@mail.gmail.com>

```
On Tue, 2010-03-23 at 14:13 +0000, Howard Miller wrote:
> >
> > git push origin +local_branch:remote_branch
> >
> 
> Thanks!
> 
> Tell me more about that '+'. I've never heard of it before. Can't see
> anything in the docs (although I'm probably not looking in the right
> place)

http://kernel.org/pub/software/scm/git/docs/git-push.html

the '+' means that you want to bypass the security which does not allow
non fast-forward pushes.

Note that you shouldn't do non fast-forward pushes to a repository which
can be cloned by other people than you. Once published (accessible to
anybody) you should do a merge and then push to origin even if you only
take your local history in the merge to avoid user pulling from origin
conflicts due to the non fast forward history.

Regards.

-- 
Sylvain Rabot <sylvain@abstraction.fr>

```

## Scott Chacon, 2010-03-23 16:05

Subject: Re: How to ignore changes on remote
Message-ID: <d411cc4a1003230905y12839743x400333a0aa2e7018@mail.gmail.com>
URL: https://gitlist.dev/e/d411cc4a1003230905y12839743x400333a0aa2e7018%40mail.gmail.com
In-Reply-To: <1269354326.14299.7.camel@kheops>

```
Why would we teach someone to do that instead of just recommending the
far less obscure 'git push -f'?  A leading '+' on the refspec is
ridiculously confusing compared to "just tell it to force the push
with -f".  Am I forgetting something?

Also, Howard, what do you mean by "I forgot to merge"?  Do other
people have push access to this branch?  You can't just tell people
"use the local version" after you force a push.  If anyone has based
work off of that point, you're going to get into way more trouble
forcing a non-ff push than if you just did a merge and then resolved
all the conflicts as --ours.

Scott

On Tue, Mar 23, 2010 at 7:25 AM, Sylvain Rabot <sylvain@abstraction.fr> wrote:
> On Tue, 2010-03-23 at 14:13 +0000, Howard Miller wrote:
>> >
>> > git push origin +local_branch:remote_branch
>> >
>>
>> Thanks!
>>
>> Tell me more about that '+'. I've never heard of it before. Can't see
>> anything in the docs (although I'm probably not looking in the right
>> place)
>
> http://kernel.org/pub/software/scm/git/docs/git-push.html
>
> the '+' means that you want to bypass the security which does not allow
> non fast-forward pushes.
>
> Note that you shouldn't do non fast-forward pushes to a repository which
> can be cloned by other people than you. Once published (accessible to
> anybody) you should do a merge and then push to origin even if you only
> take your local history in the merge to avoid user pulling from origin
> conflicts due to the non fast forward history.
>
> Regards.
>
> --
> Sylvain Rabot <sylvain@abstraction.fr>
>

```

## Howard Miller, 2010-03-23 16:13

Subject: Re: How to ignore changes on remote
Message-ID: <26ae428a1003230913s447de452rfc7b8df753885365@mail.gmail.com>
URL: https://gitlist.dev/e/26ae428a1003230913s447de452rfc7b8df753885365%40mail.gmail.com
In-Reply-To: <d411cc4a1003230905y12839743x400333a0aa2e7018@mail.gmail.com>

```
On 23 March 2010 16:05, Scott Chacon <schacon@gmail.com> wrote:
> Why would we teach someone to do that instead of just recommending the
> far less obscure 'git push -f'?  A leading '+' on the refspec is
> ridiculously confusing compared to "just tell it to force the push
> with -f".  Am I forgetting something?
>
> Also, Howard, what do you mean by "I forgot to merge"?  Do other
> people have push access to this branch?  You can't just tell people
> "use the local version" after you force a push.  If anyone has based
> work off of that point, you're going to get into way more trouble
> forcing a non-ff push than if you just did a merge and then resolved
> all the conflicts as --ours.

I'm not really fussed. I hope not to make a habit of this. I'll
probably forget and ask again next time :)

It's not a repo that particularly matters - just a convenience thing
for some test scripts. If it had been on a proper production repo then
I would just have dealt with the conflicts.

```

## Johannes Sixt, 2010-03-23 16:20

Subject: Re: How to ignore changes on remote
Message-ID: <4BA8EA6A.4030607@viscovery.net>
URL: https://gitlist.dev/e/4BA8EA6A.4030607%40viscovery.net
In-Reply-To: <d411cc4a1003230905y12839743x400333a0aa2e7018@mail.gmail.com>

```
Am 3/23/2010 17:05, schrieb Scott Chacon:
> Why would we teach someone to do that instead of just recommending the
> far less obscure 'git push -f'?  A leading '+' on the refspec is
> ridiculously confusing compared to "just tell it to force the push
> with -f".  Am I forgetting something?

-f is dangerous. I was once bitten badly by a hastily typed

   git push -f repo

that pushed two branches instead of only one: One needed an urgent update
(that was the good one), but it also pushed the other one, which was not
yet prepared for publication.

By teaching the +refspec form, you force the user to be careful which
branch is rewound. Yes, you can still say +refs/heads/*, but if you do
that, you are much more explicit than with "push -f repo", where the
affected branches are hidden in the config file.

-- Hannes

```

## Junio C Hamano, 2010-03-23 16:44

Subject: Re: How to ignore changes on remote
Message-ID: <7vtys72dj8.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vtys72dj8.fsf%40alter.siamese.dyndns.org
In-Reply-To: <d411cc4a1003230905y12839743x400333a0aa2e7018@mail.gmail.com>

```
Scott Chacon <schacon@gmail.com> writes:

> Why would we teach someone to do that instead of just recommending the
> far less obscure 'git push -f'?  A leading '+' on the refspec is
> ridiculously confusing compared to "just tell it to force the push
> with -f".  Am I forgetting something?

I think "-f" would be simpler and easier for people who use only one
branch, as there is no "I want to disable only for this branch but still
want other branches checked" problem in such a case.

Once they graduate from that and start using more than one branches, "-f"
is too broad a brush that disables the check for everything you push out,
and you would want to teach "+" as a way to narrow the possible damage.

"git push -f origin this_branch_only" can be used to limit the risk, but
if they start from a short-and-lazy "git push -f" without arguments, their
finger would have harder time to learn it.  There is no such learning
curve issue for "+", as you cannot use it without saying for which branch
to disable the check.

```

## Johan Herland, 2010-03-23 17:20

Subject: Re: How to ignore changes on remote
Message-ID: <201003231820.51618.johan@herland.net>
URL: https://gitlist.dev/e/201003231820.51618.johan%40herland.net
In-Reply-To: <4BA8EA6A.4030607@viscovery.net>

```
On Tuesday 23 March 2010, Johannes Sixt wrote:
> Am 3/23/2010 17:05, schrieb Scott Chacon:
> > Why would we teach someone to do that instead of just recommending
> > the far less obscure 'git push -f'?  A leading '+' on the refspec
> > is ridiculously confusing compared to "just tell it to force the
> > push with -f".  Am I forgetting something?
>
> -f is dangerous. I was once bitten badly by a hastily typed
>
>    git push -f repo
>
> that pushed two branches instead of only one: One needed an urgent
> update (that was the good one), but it also pushed the other one,
> which was not yet prepared for publication.

IMHO the main problem in this case is NOT with the -f option, but rather 
that 'git push' defaults to pushing all "matching" branches. I'd much 
rather have push.default default to the much safer "tracking", which 
pushes at most one branch. But changing default behaviour is hard to do 
without annoying old-timers.

I'm rolling out Git at my $DAYJOB to a few hundred developers, and I 
instruct them to

	git config --global push.default tracking

immediately after installing Git. Which sucks, but is the only sane 
thing I can do to prevent this problem from haunting us.

> By teaching the +refspec form, you force the user to be careful which
> branch is rewound. Yes, you can still say +refs/heads/*, but if you
> do that, you are much more explicit than with "push -f repo", where
> the affected branches are hidden in the config file.

IME refspecs are not easily grasped by Git newbies, and the longer they 
can get by without having to learn them, the happier they'll be with 
Git. IMHO, refspecs are really cool and powerful, but you shouldn't 
have to learn them in order to do day-to-day development.


...Johan

-- 
Johan Herland, <johan@herland.net>
www.herland.net

```

## Jakub Narebski, 2010-03-23 17:47

Subject: Re: How to ignore changes on remote
Message-ID: <hoaus7$3br$1@dough.gmane.org>
URL: https://gitlist.dev/e/hoaus7%243br%241%40dough.gmane.org
In-Reply-To: <201003231820.51618.johan@herland.net>

```
Johan Herland wrote:

> I'm rolling out Git at my $DAYJOB to a few hundred developers, and I 
> instruct them to
> 
>         git config --global push.default tracking
> 
> immediately after installing Git. Which sucks, but is the only sane 
> thing I can do to prevent this problem from haunting us.

Why not have administrator use

         git config --system push.default tracking

once (and/or setup skeleton for /etc/gitconfig)?
-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

```

## Johan Herland, 2010-03-23 18:02

Subject: Re: How to ignore changes on remote
Message-ID: <201003231902.35962.johan@herland.net>
URL: https://gitlist.dev/e/201003231902.35962.johan%40herland.net
In-Reply-To: <hoaus7$3br$1@dough.gmane.org>

```
On Tuesday 23 March 2010, Jakub Narebski wrote:
> Johan Herland wrote:
> > I'm rolling out Git at my $DAYJOB to a few hundred developers, and
> > I instruct them to
> >
> >         git config --global push.default tracking
> >
> > immediately after installing Git. Which sucks, but is the only sane
> > thing I can do to prevent this problem from haunting us.
>
> Why not have administrator use
>
>          git config --system push.default tracking
>
> once (and/or setup skeleton for /etc/gitconfig)?

Because developers administer their own machines.


...Johan

-- 
Johan Herland, <johan@herland.net>
www.herland.net

```
