问题描述
Line one
Line two
Line four
每行已添加到单独的提交中。
Line one
Line two
Line three
Line four
此bash脚本设置存储库:
#!/bin/bash
mkdir -p ~/testrepo
cd ~/testrepo || exit
git init
echo 'Line one' >> myfile.txt
git add myfile.txt
git commit -m 'First commit'
echo 'Line two' >> myfile.txt
git commit -m 'Second Commit' myfile.txt
echo 'Line four' >> myfile.txt
git commit -m 'Third commit' myfile.txt
sed -i '/Line two/a Line three' myfile.txt
git commit --fixup=HEAD^ myfile.txt
历史看起来像这样
$ git --no-pager log --oneline
90e29ee (HEAD -> master) fixup! Second Commit
6a20f1a Third commit
ac1564b Second Commit
d8a038d First commit
我运行了一个交互式基础,将修订提交合并到“第二个提交”中,但是它报告了合并冲突:
$ git rebase -i --autosquash HEAD^^^
Auto-merging myfile.txt
CONFLICT (content): Merge conflict in myfile.txt
error: Could not apply 90e29ee... fixup! Second Commit
Resolve all conflicts manually,mark them as resolved with
"git add/rm <conflicted_files>",then run "git rebase --continue".
You can instead skip this commit: run "git rebase --skip".
To abort and get back to the state before "git rebase",run "git rebase --abort".
Could not apply 90e29ee... fixup! Second Commit
$ git --no-pager diff
diff --cc myfile.txt
index b8b933b,43d9d5b..0000000
--- a/myfile.txt
+++ b/myfile.txt
@@@ -1,2 -1,4 +1,7 @@@
Line one
Line two
++<<<<<<< HEAD
++=======
+ Line three
+ Line four
++>>>>>>> 90e29ee... fixup! Second Commit
- 为什么将fixture提交从分支的HEAD移到“ Second Commit”和“ Third Commit”之间的位置会产生合并冲突?
- 有没有一种方法可以执行重新设置基准并避免冲突,或者可以自动解决冲突?
所需的历史记录将是
xxxxxxx (HEAD -> master) Third commit
xxxxxxx Second Commit
d8a038d First commit
“第二次提交”如下所示:
diff --git a/myfile.txt b/myfile.txt
index e251870..802f69c 100644
--- a/myfile.txt
+++ b/myfile.txt
@@ -1 +1,3 @@
Line one
+Line two
+Line three
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)