如何忽略合并冲突? [英] How to ignore merge conflict?

查看:86
本文介绍了如何忽略合并冲突?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下一个合并冲突:

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

如果仅在空格中有更改,是否可以忽略这种冲突?就像-w -b选项

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

推荐答案

好吧,您不能忽略冲突,因为那意味着有些错误,您必须告诉Git您已解决了冲突.

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

如果您真的想保持文件原样,则可以删除冲突差异行,然后git add/git commit冲突的文件,以便保留文件的所有行.

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.

否则,如果您要保留文件的特定版本("theirs",即您试图合并到本地代码库中的内容,或"ours",即您的代码库),则可以使用:

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

git checkout --theirs my/file

那么请不要忘记提交文件,以使git不在这种怪异冲突模式下.

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

这篇关于如何忽略合并冲突?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆