Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 687
Eugen Konkov Avatar asked Jan 03 '23 21:01

Eugen Konkov


2 Answers

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.

like image 70
MeuhMeuh Avatar answered Jan 05 '23 16:01

MeuhMeuh


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

like image 26
Nyobord Moga Avatar answered Jan 05 '23 14:01

Nyobord Moga