在git中创建一个包含特定文件的补丁 [英] Create a patch including specific files in git

查看:78
本文介绍了在git中创建一个包含特定文件的补丁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我在提交原始/主回购之前提交了7份。我想创建一个修补程序,其中包含修改后的修补程序特定文件,而不是所有文件。或者等价物从修补程序中排除特定文件。我可以如何实现这一点?

解决方案

您可以限制 git diff - 之后以避免路径名称和分支名称之间出现任何潜在的冲突)。例如,您可以执行以下操作:

  git diff origin / master HEAD  -  app / models / region.rb doc / > changes.patch 

...生成一个只显示特定文件和一个特定目录。


Let's say that I am 7 commits ahead of the origin/master repo. I would like to create a patch that includes in the patch specific files that were changed, not all the files. Or equivalent exclude specific files from the patch that were changed. How can I achieve that?

解决方案

You can restrict the output of git diff by listing paths at the end of the command (after a -- to avoid any potential clashes between path names and branch names). For example, you could do the following:

git diff origin/master HEAD -- app/models/region.rb doc/ > changes.patch

... to generate a patch that only shows the differences within a particular file and a particular directory.

这篇关于在git中创建一个包含特定文件的补丁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆