这是交易。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
不记得冲突解决方案(实际上错误地将文件留在树中)。