这是交易。 master有一个文件file1。我分支,并删除分支中的该文件。同时,我修改了master上的file1。热潮,冲突。
当我将分支合并为master时,解决方法是删除该文件。我正在尝试使用git rerere
能够多次执行相同的分辨率,但正如您在下面所看到的那样,当您删除文件时,它不会记录分辨率。
我无法找到任何专门的文档,这只是rerere
的限制吗?
|system| brad-macbook-air in ~/tmp
± bb+ih |master ✓| → touch file1.txt
|system| brad-macbook-air in ~/tmp
± bb+ih |master ✗| → git add . && git commit -m 'File1'
[master (root-commit) 95a807e] File1
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 file1.txt
|system| brad-macbook-air in ~/tmp
± bb+ih |master ✓| → git checkout -b delete_file_1
Switched to a new branch 'delete_file_1'
|system| brad-macbook-air in ~/tmp
± bb+ih |delete_file_1 ✓| → git rm file1.txt
rm 'file1.txt'
|system| brad-macbook-air in ~/tmp
± bb+ih |delete_file_1 ✗| → git commit -m 'rm file1'
[delete_file_1 83d1a57] rm file1
1 file changed, 0 insertions(+), 0 deletions(-)
delete mode 100644 file1.txt
|system| brad-macbook-air in ~/tmp
± bb+ih |delete_file_1 ✓| → git checkout master
Switched to branch 'master'
|system| brad-macbook-air in ~/tmp
± bb+ih |master ✓| → echo 'hello' > file1.txt
|system| brad-macbook-air in ~/tmp
± bb+ih |master ✗| → git commit -am 'update file1'
[master 16f6541] update file1
1 file changed, 1 insertion(+)
|system| brad-macbook-air in ~/tmp
± bb+ih |master ✓| → git merge delete_file_1
CONFLICT (modify/delete): file1.txt deleted in delete_file_1 and modified in HEAD. Version HEAD of file1.txt left in tree.
Automatic merge failed; fix conflicts and then commit the result.
|system| brad-macbook-air in ~/tmp
± bb+ih |master ✗| → git rm file1.txt
file1.txt: needs merge
rm 'file1.txt'
|system| brad-macbook-air in ~/tmp
± bb+ih |master ✗| → git commit --no-edit
[master 4791204] Merge branch 'delete_file_1'
在这里,我们应该看到像“file1.txt的记录分辨率”这样的内容,但我们没有。为了确保它没有记录我们的分辨率,我们继续进行并再次进行完全相同的合并:
|system| brad-macbook-air in ~/tmp
± bb+ih |master ✓| → git reset head^
Unstaged changes after reset:
D file1.txt
|system| brad-macbook-air in ~/tmp
± bb+ih |master ✗| → git co .
|system| brad-macbook-air in ~/tmp
± bb+ih |master ✓| → git merge delete_file_1
CONFLICT (modify/delete): file1.txt deleted in delete_file_1 and modified in HEAD. Version HEAD of file1.txt left in tree.
Automatic merge failed; fix conflicts and then commit the result.
在这里你可以看到git rerere
不记得冲突解决方案(实际上错误地将文件保留在树中)。
答案 0 :(得分:4)
正如它现在的方式,号码rerere试图在每个冲突文件中记录基于帅哥的先前分辨率。在删除的情况下,rerere认为它只是没有解决的问题。
答案 1 :(得分:0)
当功能分支包含主分支中不存在的新文件时,我也遇到了问题,但为了使功能分支合并到主分支中并使其正常工作,需要进行少量修改到这个新文件。 git rerere并没有意识到这是整个合并过程的一部分,因此永远不会记录所需的更改。