gpt4 book ai didi

git - 当解决方案是删除冲突文件时,有没有办法让 git rerere 工作?

转载 作者:太空狗 更新时间:2023-10-29 12:54:43 25 4
gpt4 key购买 nike

这是交易。 master 有一个文件,file1。我分支,并删除分支中的那个文件。同时,我在 master 上修改 file1。繁荣,冲突。

当我将我的分支 merge 到 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 记录分辨率”的内容,但我们没有看到。为了确保它没有记录我们的决议,我们继续前进并再次进行完全相同的 merge :

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

最佳答案

就目前的情况而言,No.rerere 尝试根据每个冲突文件中的 hunk 记录以前的解决方案。在删除的情况下,rerere 仅将其视为没有要解决的问题。

关于git - 当解决方案是删除冲突文件时,有没有办法让 git rerere 工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30743861/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com