git status和git diff空失败后git我
我正在开发一个不同的机器,而不是我通常做的,似乎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
啊哈! This SO post led me to an answer.
两个事情出错:
设置三路合并为git am
默认行为:
git config --global am.threeWay true
这是由事实混淆,我做了一个浅拷贝(即。 --depth 1
)。我链接到的SO帖子解释说,没有足够的历史记录,警告fatal: sha1 information is lacking or useless
说“没有足够的信息构建三路合并”。
这将是在这种情况下,如果提到你做了一个浅拷贝来获取更多的历史很有帮助它混帐......
本身肯定需要是强化的消息。我也会将'git fetch --unshallow'提示添加到我的其他答案中。 – torek