繁体   English   中英

修复 git rebase

[英]fixing the git rebase

我对我的代码进行了更改,而我的队友也对他们进行了更改,我进行了提交,与他们的相同,因此我们最终更改了大部分文件

推开他的树枝,然后我拉它,

我从 git bash 收到了这条消息。

First, rewinding head to replay your work on top of it...
Applying: Fixed the account control problem
Using index info to reconstruct a base tree...
M       application/views/templates/header.php
.git/rebase-apply/patch:417: trailing whitespace.
<?php
.git/rebase-apply/patch:418: trailing whitespace.
defined('BASEPATH') OR exit('No direct script access allowed');
.git/rebase-apply/patch:427: trailing whitespace.
$autoload['libraries'] = array('ion_auth');
.git/rebase-apply/patch:436: trailing whitespace.
$autoload['helper'] = array('form');
.git/rebase-apply/patch:451: trailing whitespace.
$config['tables']['groups']          = 'groups';
warning: squelched 772 whitespace errors
warning: 777 lines add whitespace errors.
Falling back to patching base and 3-way merge...
Auto-merging application/views/templates/header.php
CONFLICT (content): Merge conflict in application/views/templates/header.php
error: Failed to merge in the changes.
Patch failed at 0001 Fixed the account control problem
The copy of the patch that failed is found in: .git/rebase-apply/patch

When you have resolved this problem, run "git rebase --continue".
If you prefer to skip this patch, run "git rebase --skip" instead.
To check out the original branch and stop rebasing, run "git rebase --abort"

问题是,git 显示文件未暂存,当我尝试提交它时,我无法继续重新设置基准,如果我运行,git rebase --skip,我提取的文件也丢失了。

对此的正确解决方案是什么? 这是我第一次遇到它。

我推测,当您执行 pull 时,您实际上执行了git pull --rebase ,即在 rebase 模式下 pull。 这意味着您在远程存在的版本之上重新建立了本地分支。 完成 rebase 的一般方法是对每个出现在CONFLICT文件采取以下步骤:

  • 手动解决文件中的合并冲突
  • 在每个文件上执行git add
  • 解决所有冲突后,执行git rebase --continue


好消息是,您向我们展示的 rebase 步骤只有header.php存在冲突。 但是,rebase 的每一步都对应于重新应用您的一个本地提交,并且在 rebase 的后续步骤中可能存在多个文件中的冲突。

鉴于您当前的 rebase 尝试可能弄得一团糟,您可能想要git rebase --abort然后再次拉取。

另一种选择是使用合并作为策略。 这只是一个步骤,会导致所有文件同时出现冲突。 但也许您的组织正在实施变基工作流程。

打开application/views/templates/header.php

删除“HEAD”和“======”之类的语句。

git add application/views/templates/header.phpheader.php添加到索引

运行git rebase --continue

拉取远程分支后,在某些文件中发生冲突。 如果您想保持remote/changes则接受--theirs否则接受--ours

$ git pull origin <branch-name>

$ git checkout --theirs -- .             # accept remote (--theirs) changes
$ git add .
$ git commit -m 'Fix conflicts'
$ git push origin HEAD

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM