git am: Patch format detection failed

断了今生、忘了曾经 提交于 2020-01-01 09:24:41

问题


I have never used patches with Git before and I need some help. I am trying to apply a patch to a Git repo to test a Wine patch, specifically this patch here. So I did the following:

$ git clone git://source.winehq.org/git/wine.git
$ cd wine
$ nano patch.p1

I then pasted the content of the patch with Ctrl+Shift+Vand used Ctrl+O to save. Then I tried this:

$ git am patch.p1
Patch format detection failed.

What am I doing wrong? I have never applied a patch before.


回答1:


Patch format detection failed. probably means you're using the wrong command: use git apply instead of git am or the other way around.

See What is the difference between git am and git apply? for more on the difference between the 2.




回答2:


Use below command: patch -p1 < patch_file_name.patch

  • You will be asked to specify "File to patch", mention complete path /
  • Assume -R [n]: n
  • Apply anyway? [n]: y

Do for all files present in you patch.

  • If any merge conflict occurs then check the conflict in ".rej" file which has been generated and resolve & apply those changes.
  • do "git add " and "commit" your changes.


来源:https://stackoverflow.com/questions/49313250/git-am-patch-format-detection-failed

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!