我正在開發一個不同的機器,而不是我通常做的,似乎git的行爲與我記憶中的不同。git status和git diff空失敗後git我
當我籤一個新的分支git checkout -b <new branch name>
,並嘗試應用補丁git am </path/to/file.patch>
,補丁未申請:
</path/to/file.patch>
Applying: <commit msg>
error: patch failed: <filename>:<line no>
error: <filename>: patch does not apply
Patch failed at <commit msg>
The copy of the patch that failed is found in: .git/rebase-apply/patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
現在,我在我的其他機器發誓當補丁逾期不申請,git status
和git diff
將顯示文件修改爲<<<HEAD>>>>
標記,顯示我需要修復三路合併的位置。目前git status
顯示我處於am
操作的中間,但沒有更改文件,git diff
也一樣。
我忘了還是我的其他機器可能有舊版本的git
,甚至是不同的配置選項集?爲什麼git不顯示合併衝突?我需要設置一個mergetool嗎?我目前無法訪問我的其他機器,但我會嘗試在更新信息時更新此帖子。
編輯:
git am --3way
似乎是我想要的。 [0] [1]但是git am --3way <path/to/patch>
和git config --global am.threeWay true
似乎都不起作用。
啊,它的失敗與現在不同的信息:
</path/to/file.patch>
Applying: <commit msg>
fatal: sha1 information is lacking or useless (<filename>). <-- new
error: could not build fake ancestor <-- new
Patch failed at <commit msg>
The copy of the patch that failed is found in: .git/rebase-apply/patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
與之相似,git am --3way </path/to/patch>
失敗:
error: patch failed: <file>:<lineno>
error: repository lacks the necessary blob to fall back on 3-way merge.
error: Makefile: patch does not apply
也許這個補丁是不能贖回?採取patch -p1 < </path/to/path>
適用於第一塊,並在第二塊失敗,所以我想我必須手工完成。
我應該注意到,我正在用--depth 1
克隆的淺回購工作。
[0] https://www.kernel.org/pub/software/scm/git/docs/git-am.html [1] https://www.kernel.org/pub/software/scm/git/docs/git-config.html
本身肯定需要是強化的消息。我也會將'git fetch --unshallow'提示添加到我的其他答案中。 – torek