How to ignore merge conflict?

一笑奈何 提交于 2019-12-02 23:35:04

问题


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


回答1:


Well, you cannnot 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.



来源:https://stackoverflow.com/questions/48490000/how-to-ignore-merge-conflict

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!