用Git创建补丁-只保留文件路径的basename?

用Git创建补丁-只保留文件路径的basename?,git,patch,Git,Patch,我的情况是,我正在对已安装的Drupal模块进行更改,我希望将其提交回开放源码项目yay。我的问题是: diff --git a/docroot/profiles/commons/modules/contrib/features/features.drush.inc b/docroot/profiles/commons/modules/contrib/features/features.drush.inc index 0d7a10d..ae5e88b 100644 --- a/docroot/p

我的情况是,我正在对已安装的Drupal模块进行更改,我希望将其提交回开放源码项目yay。我的问题是:

diff --git a/docroot/profiles/commons/modules/contrib/features/features.drush.inc b/docroot/profiles/commons/modules/contrib/features/features.drush.inc
index 0d7a10d..ae5e88b 100644
--- a/docroot/profiles/commons/modules/contrib/features/features.drush.inc
+++ b/docroot/profiles/commons/modules/contrib/features/features.drush.inc
显然,这些是补丁文件的前几行,告诉patch命令在哪里找到要修补的文件。但是,鉴于我想将其提交回Features项目,我想将其切掉,以便从路径中删除docroot/profiles/commons/modules/contrib/Features/。因此,上面应该是这样的:

diff --git a/features.drush.inc b/features.drush.inc
index 0d7a10d..ae5e88b 100644
--- a/features.drush.inc
+++ b/features.drush.inc
我已经查看了man git diff,但我没有看到这样做,即只保留文件名。我可能是瞎了

TL;博士


使用Git创建修补程序文件时,如何仅保留文件路径的基本名称?

Git diff的-relative选项可以做到这一点。

Git diff的-relative选项可以做到这一点。

为什么不编辑修补程序呢?我的思路是,这是我刚才假设的修补程序文件世界中常见的事情您可以在命令行上以某种方式标记它。@KevinBallard,对于一次性作业可以;如果它可以正常使用,或者补丁会接触到很多文件,那么最好自动化…为什么不编辑补丁呢?我的想法是,这是你在补丁文件世界中看到的一件很常见的事情,我只是假设你可以在命令行上以某种方式标记它。@KevinBallard,可以一次完成任务;如果它将与任何规则使用或补丁触及许多文件,更好地自动化。。。