如何应用使用 `git-log -p` 创建的补丁文件来创建包含的所有提交?
背景: 这个问题。 git apply
Background: this question. git apply <patchfile>
just recreates the file but without committing the history, which in this case would be desireable. Is there any switch for git-apply
to do so? Or is there a way to convert the patchfile into a git-am
compatible file? (Currently, git-am complains "Patch format detection failed")
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你问了,所以就在这里。
我使用了这个脚本,但它相当脆弱。将其视为灵感,而不是合理的解决方案。
它从 git log -p 的输出中提取(日期/作者/提交消息/补丁),然后运行
patch
+git add
+< code>git apply 对于所有,按相反的顺序。可能有某种方法可以自动找出正确的
patch_level
,但我没有打扰。如果不是您的全部,请将作者传递给git apply
。You asked, so here it is.
I used this script, but it's all rather fragile. Treat it an as inspiration, not as a reasonable solution.
It extracts (date / author / commit message / patch) from output of
git log -p
, and then runspatch
+git add
+git apply
for all, in reverse order.There's probably some way of automatically figuring out correct
patch_level
, but I didn't bother. And pass author togit apply
if it's not all you.查看
git quiltimport
。您提供一个目录,命令在其中查找名为“series”的文件。在此文件中,您只需提及补丁文件的名称,以便应用它们”。文件中实际差异之前的文本用作提交注释,文件名(减去 .patch)用作标题,它会尝试在每个补丁中找到作者,如果没有找到,则会要求您提供。look into
git quiltimport
. You provide a directory where the command finds a file called "series". In this file you simply mention the names of the patchfiles, in order which it will apply them". The text prior to the actuall diff in the file is used as commit comment, the filename (minus the .patch) is used as headline, and it tries to find the author in each patch, if none are found you get asked for it.