强制逐个文件合并-git [英] Force merge file by file - git

查看:79
本文介绍了强制逐个文件合并-git的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚合并了两个分支"branch1"和"branch2".问题在于,现在这里充满了很多冲突,有时内容重复(是否可能??).

I have just merged two branches 'branch1' and 'branch2'. The problem is that it is now a mess with a lot of conflicts, with sometimes duplicate contents (is it possible ??).

我想做的是强制将"branch1"中的某些文件与"branch2"合并,反之也迫使"branch2"中的某些文件与"branch1"合并,因为我现在位于"branch1"上'.有可能吗?

What I want to do is to force for some files from 'branch1' to be merged against 'branch2' and conversely to force some files from 'branch2' to be merged against 'branch1', knowing I am now on 'branch1'. Is it possible ?

更新:git-merge似乎有问题?假设我保留了branch1版本,然后

Update : there seems to be problem with git-merge ? Suppose I keep the branch1 version, then

echo $this->fetch('prehome.html');
        die; 

会出现两次,请参阅:

protected function prehomepage()
    {
        $var = 'myvar';

        echo $this->fetch('prehome.html');
        die;
    }

<<<<<<< HEAD
    $this->mySmarty->assign('title', 'Primagora');

    echo $this->fetch('prehome.html');
    die;
  }

  /**
   * Generate the campaign block for the general sidebar, called through AJAX.
   */
  protected function getCampaignBlock()
  {
    $from = Utils::fromGet('from');
    echo $this->getCampaignSidebarBlock($from);
    die();
  }
=======
    /**
     * Generate the campaign block for the general sidebar, called through AJAX.
     */
    protected function getCampaignBlock()
    {
        $from = Utils::fromGet('from');
        echo $this->getCampaignSidebarBlock($from);
        die();
    }
>>>>>>> branch2

推荐答案

在发生冲突的情况下(如果设置了git config merge.conflictstyle diff3),您可以:

On a merge with conflicts (if git config merge.conflictstyle diff3 is set) , you can:

  • 忽略合并并保留您的原始版本(来自branch1):

git show :2:full_path > file
# or 
git checkout-index --stage=2 -- file

  • 忽略合并并保留其他版本(来自branch2):
    • ignore that merge and keep the other version (from branch2):
    • 
      git show :3:full_path > file
      # or 
      git checkout-index --stage=3 -- file
      

      从那里开始git addgit commit.

      这篇关于强制逐个文件合并-git的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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