threads / discuss / 19392

Merging a branch when I don't want conflicts

Subject: Merging a branch when I don't want conflicts

## tl;dr

8 messages between May 18, 2009 and May 18, 2009.

replies: 7people: 5as markdown or json

Geoff Russell· May 18, 2009, 02:30 UTC · lore

How do I merge a branch X into my master and tell git that whenever there is a conflict, the file on X should prevail? This is for a scripted application.

Cheers, Geoff

Johannes Sixt· May 18, 2009, 06:18 UTC · re: Geoff Russell · lore

Re: Merging a branch when I don't want conflicts

Geoff Russell schrieb:
> How do I merge a branch X into my master and tell git that whenever there
> is a conflict, the file on X should prevail?  This is for a scripted
> application.
I assume you talk about file-level (content) merges.

There is no such tool, and the reason is that what you try to do here does not make sense *in general*. It must be a very special kind of project where you can blindly trust one side over the other if there are conflicts, and that you can additionally trust non-conflicting content merges.

The best you can do is perhaps to pipe conflicting files through
    sed -e '/^<<<<<<</,/^=======/d' -e '/^>>>>>>>/d'
-- Hannes
Geoff Russell· May 18, 2009, 08:05 UTC · re: Johannes Sixt · lore

Re: Merging a branch when I don't want conflicts

On 5/18/09, Johannes Sixt <j.sixt@viscovery.net> wrote:
Show 8 quoted lines
> Geoff Russell schrieb:
>
> > How do I merge a branch X into my master and tell git that whenever there
>  > is a conflict, the file on X should prevail?  This is for a scripted
>  > application.
>
>
> I assume you talk about file-level (content) merges.
Yes.
Show 5 quoted lines
>
>  There is no such tool, and the reason is that what you try to do here does
>  not make sense *in general*. It must be a very special kind of project
>  where you can blindly trust one side over the other if there are
>  conflicts, and that you can additionally trust non-conflicting content merges.

The file is data coming out of an interactive program which reads the entire file, edits and then writes the entire file at which point this file is correct and all previous versions are obsolete. I don't really want a merge at all, but just want to replace the file in the master with the version on the branch.

Thanks anyway.

Cheers, Geoff.

Show 8 quoted lines
>
>  The best you can do is perhaps to pipe conflicting files through
>
>     sed -e '/^<<<<<<</,/^=======/d' -e '/^>>>>>>>/d'
>
>  -- Hannes
>
>
-- 
6 Fifth Ave,
St Morris, S.A. 5068
Australia
Ph: 041 8805 184 / 08 8332 5069
Johannes Sixt· May 18, 2009, 09:01 UTC · re: Geoff Russell · lore

Re: Merging a branch when I don't want conflicts

Geoff Russell schrieb:
Show 6 quoted lines
> The file is data coming out of an interactive program which reads
> the entire file, edits and then writes the entire file at which point
> this file is correct
> and all previous versions are obsolete.  I don't really want a merge
> at all, but just
> want to replace the file in the master with the version on the branch.
Ah, so finally you say what you mean ;)

You can define a custom merge driver that always returns the content of the second branch. See 'man gitattributes'.

-- Hannes
Geoff Russell· May 18, 2009, 23:53 UTC · re: Johannes Sixt · lore

Re: Merging a branch when I don't want conflicts

On Mon, May 18, 2009 at 6:31 PM, Johannes Sixt <j.sixt@viscovery.net> wrote:
Show 15 quoted lines
> Geoff Russell schrieb:
>> The file is data coming out of an interactive program which reads
>> the entire file, edits and then writes the entire file at which point
>> this file is correct
>> and all previous versions are obsolete.  I don't really want a merge
>> at all, but just
>> want to replace the file in the master with the version on the branch.
>
> Ah, so finally you say what you mean ;)
>
> You can define a custom merge driver that always returns the content of
> the second branch. See 'man gitattributes'.
>
> -- Hannes
>

Sorry for the confusion. A custom merge driver will work fine ... but I will also rethink carefully what I am doing.

Cheers, Geoff.

Nanako Shiraishi· May 18, 2009, 10:45 UTC · re: Johannes Sixt · lore

Re: Merging a branch when I don't want conflicts

Quoting Johannes Sixt <j.sixt@viscovery.net>:
Show 17 quoted lines
> Geoff Russell schrieb:
>> How do I merge a branch X into my master and tell git that whenever there
>> is a conflict, the file on X should prevail?  This is for a scripted
>> application.
>
> I assume you talk about file-level (content) merges.
>
> There is no such tool, and the reason is that what you try to do here does
> not make sense *in general*. It must be a very special kind of project
> where you can blindly trust one side over the other if there are
> conflicts, and that you can additionally trust non-conflicting content merges.
>
> The best you can do is perhaps to pipe conflicting files through
>
>     sed -e '/^<<<<<<</,/^=======/d' -e '/^>>>>>>>/d'
>
> -- Hannes
I think -Xours enhancement that was developed long time ago
    http://thread.gmane.org/gmane.comp.version-control.git/76650/focus=89021
should help Geoff's use case.
-- 
Nanako Shiraishi
http://ivory.ap.teacup.com/nanako3/
Tay Ray Chuan· May 18, 2009, 15:57 UTC · re: Nanako Shiraishi · lore

Re: Merging a branch when I don't want conflicts

Hi,
On Mon, May 18, 2009 at 6:45 PM, Nanako Shiraishi <nanako3@lavabit.com> wrote:
> I think -Xours enhancement that was developed long time ago
I think this is now called -s ours/--strategy=ours:
http://www.kernel.org/pub/software/scm/git/docs/git-merge.html
-- 
Cheers,
Ray Chuan
Junio C Hamano· May 18, 2009, 16:17 UTC · re: Tay Ray Chuan · lore

Re: Merging a branch when I don't want conflicts

Tay Ray Chuan <rctay89@gmail.com> writes:
Show 8 quoted lines
> Hi,
>
> On Mon, May 18, 2009 at 6:45 PM, Nanako Shiraishi <nanako3@lavabit.com> wrote:
>> I think -Xours enhancement that was developed long time ago
>
> I think this is now called -s ours/--strategy=ours:
>
> http://www.kernel.org/pub/software/scm/git/docs/git-merge.html
Read it again.  -Xours is very different from -s ours.

← back to recent threads