我如何指示 git diff 不要将附近的帅哥放在一起?

How can I instruct git diff NOT to batch together hunks that are near by?

本质上,我希望 git diff 到 return 与 returned 相同的帅哥,当我选择在交互式 rebase 中拆分帅哥时。

我使用的命令是:

git diff -U3 -r -M

它可以产生这样的东西:

@@ -70,10 +70,10 @@
   "GetAllDeptJobs2": "None",
   "GetAllDeptJobsSlim": "None",
   "GetAllDirectDeposits": "Payroll (*)",
-  "GetAllEmployeeBenPlanElectedOptions": "None",
+  "GetAllEmployeeBenPlanElectedOptions": "Benefits (*)",
   "GetAllEmployeeConfidentialIdentifications": "HR (*)",
-  "GetAllEmployeeDeductionBenElectedRates": "None",
-  "GetAllEmployeeEarningBenElectedRates": "None",
+  "GetAllEmployeeDeductionBenElectedRates": "Benefits (*)",
+  "GetAllEmployeeEarningBenElectedRates": "Benefits (*)",
   "GetAllEmployeeElectedBenefitBeneficiary": "None",
   "GetAllEmployeeElectedBenefitBeneficiaryAndDependentData": "None",
   "GetAllEmployeeElectedBenefitBeneficiarySL": "None",

相应文件的相关部分(应用更改后)是:

  "GetAllDeptJobs2": "None",
  "GetAllDeptJobsSlim": "None",
  "GetAllDirectDeposits": "Payroll (*)",
  "GetAllEmployeeBenPlanElectedOptions": "Benefits (*)",
  "GetAllEmployeeConfidentialIdentifications": "HR (*)",
  "GetAllEmployeeDeductionBenElectedRates": "Benefits (*)",
  "GetAllEmployeeEarningBenElectedRates": "Benefits (*)",
  "GetAllEmployeeElectedBenefitBeneficiary": "None",
  "GetAllEmployeeElectedBenefitBeneficiaryAndDependentData": "None",
  "GetAllEmployeeElectedBenefitBeneficiarySL": "None",

我想知道这两个帅哥是分开的。我意识到第一个大块的尾随上下文与第二个大块的增量重叠,但那又怎样?我想得到以下两个帅哥:

@@ -70,7 +70,7 @@
   "GetAllDeptJobs2": "None",
   "GetAllDeptJobsSlim": "None",
   "GetAllDirectDeposits": "Payroll (*)",
-  "GetAllEmployeeBenPlanElectedOptions": "None",
+  "GetAllEmployeeBenPlanElectedOptions": "Benefits (*)",
   "GetAllEmployeeConfidentialIdentifications": "HR (*)",
   "GetAllEmployeeDeductionBenElectedRates": "None",
   "GetAllEmployeeEarningBenElectedRates": "None",

@@ -72,10 +72,10 @@
   "GetAllDirectDeposits": "Payroll (*)",
   "GetAllEmployeeBenPlanElectedOptions": "None",
   "GetAllEmployeeConfidentialIdentifications": "HR (*)",
-  "GetAllEmployeeDeductionBenElectedRates": "None",
-  "GetAllEmployeeEarningBenElectedRates": "None",
+  "GetAllEmployeeDeductionBenElectedRates": "Benefits (*)",
+  "GetAllEmployeeEarningBenElectedRates": "Benefits (*)",
   "GetAllEmployeeElectedBenefitBeneficiary": "None",
   "GetAllEmployeeElectedBenefitBeneficiaryAndDependentData": "None",
   "GetAllEmployeeElectedBenefitBeneficiarySL": "None",

我明白git diff为什么要对这两个大佬进行批处理,但是是否仍然可以单独获取它们并能够成功应用补丁?

虽然git diff (may U1 would work?), it is with git add -p (--patch)不直接支持

通过为“smaller”键入“s”,您将获得两个大块头而不是一个,并且将能够应用您的第一组更改,而不应用第二组。

从那里,您可以 generate a patch from your staged changes

git diff --cached > mypatch.patch

它将只包含第一个大块头。