我遇到了我無法解釋的合併行爲。以下腳本初始化存儲庫,並通過修改和重命名來創建一些分支。爲什麼git無法合併具有修改的重命名?
$ git init
$ emacs file.txt
$ cat file.txt
1
2
3
4
$ git add file.txt && git ci -m "initial"
$ git branch A && git branch B && git branch C && git branch D
$ git checkout A
$ emacs file.txt
$ cat file.txt
1
added after 1
2
3
4
$ git add file.txt && git commit -m "edited in A"
$ git checkout B
$ emacs file.txt
$ cat file.txt
1
2
3
added after 3
4
$ git add -u && git commit -m "edited in B"
$ git checkout C
$ git mv file.txt f.txt
$ git commit -m "renamed in C"
$ git checkout D
$ git mv file.txt f.txt
$ git commit -m "renamed in D"
$ emacs f.txt
$ cat f.txt
1
2
3
added after 3
4
$ git add -u && git commit -m "edited in D (after rename)"
有了這樣的:
- 如果你嘗試「混帳結賬乙& &混帳合併A」合併將沒有任何衝突來完成。
- 如果您嘗試'git checkout C & & git merge'合併將完成沒有任何衝突。
- 如果你嘗試 '混帳結賬d & &混帳合併A',你會得到:
衝突(重命名/刪除):在f.txt刪除和重命名HEAD。 版本f.txt的HEAD留在樹中。
在案例2中的git檢測到重命名分支C和從而成功地合併從分支A.變化
萬一3,我不明白爲什麼git的不能合併來自兩個支路甚至改變成功重命名檢測後。
$ git --version
git version 1.9.3 (Apple Git-50)
如果我記得默認是80%的文件內容匹配,但我永遠不會期望這樣的工作合理與這樣的小文件。 – U2EF1