Search code examples
gitmerge-conflict-resolution

How to ignore merge conflict?


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


Solution

  • 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.