5

I have next merge conflict:

<<<<<<< Updated upstream
    my( $c, $name ) =  (shift,shift);
  my %name =  defined $name ? ( name => $name ) : ();

||||||| merged common ancestors
    my( $c ) =  shift;
=======
    my( $c, $name ) =  (shift,shift);

  my %name =  defined $name ? ( name => $name ) : ();
>>>>>>> Stashed changes

<<<<<<< Updated upstream
    return $c->render_to_string( 'control/toggle', id => "toggle$id", %name, @_ );
||||||| merged common ancestors
  return $c->render_to_string( 'control/toggle', @_, id => "toggle$id" );
=======
    return $c->render_to_string( 'control/toggle', id => "toggle$id",  %name,  @_ );
>>>>>>> Stashed changes

Is there an option to ignore such conflicts if there are only changes in whitespace? Just like -w -b options

Eugen Konkov
  • 22,193
  • 17
  • 108
  • 158
  • I can't even see the whitespace difference in the first conflict (it's clear in the second conflict: comma space space percent-sign `name`), but no, there's no such option. – torek Jan 28 '18 at 21:27
  • @torek: In first example there is empty line difference. What do you think, will it be useful such option? – Eugen Konkov Jan 29 '18 at 07:50
  • Given that Git has *some* white space handling (mostly at end-of-lines though), if you generalized it and made it workable with `git apply` and `git merge` both, it might well be useful. – torek Jan 29 '18 at 15:32

2 Answers2

13

Well, you can not ignore conflicts, because that means that something is wrong, and you have to tell Git that you fixed the conflict.

If you really want to keep the file as-is, you can remove the conflict diff lines, and then git add / git commit the files that were in conflict so that you keep all lines of the file.

Else, if you want to keep a specific version (either "theirs", meaning what you tried to merge into your local codebase or "ours", meaning your codebase) of the file, you can use :

git checkout --ours my/file

Or

git checkout --theirs my/file

Don't forget, then, to commit the files so that git is not in this weirdo conflict mode.

Eugen Konkov
  • 22,193
  • 17
  • 108
  • 158
MeuhMeuh
  • 826
  • 6
  • 26
4

The simplest way, if you have unmerged paths, use git merge --abort to abort the merge. This way your code will look the same as it was before trying to merge with some other branch...