git 暂存补丁:大块小于一条线
git staging patches: with hunk smaller than a line
我希望从一个独特的提交中制作一个交互式补丁。我想使用类似于
的输出
git diff --word-diff=porcelain [file]
用于交互式修补。命令
git add --edit
只推荐至少一行的帅哥?
目标:我有一个文本文件的补丁,我想像 "LibreOffice" 接受或拒绝更改那样进行更改。
示例:
一行文本文件:
echo "Thiis is a sentence with one wrong word. This is a clean sentence. Thhe laast one iss alwaays morre dificult" > text.txt
提交
git add text.txt
git commit -m "one"
修改文件
echo "This is a sentence with one wrong word. This is a clean sentence. The last one is always more difficult" > text.txt
git add -e
应该会自动剪成3块
"Thiis" > "This"
"Thhe laast" > "The last"
"iss alwaays morre dificult"> "is always more difficult"
刚好可以得到
--- a/text.txt
+++ b/text.txt
@@ -1 +1 @@
-Thiis is a sentence with one wrong word. This is a clean sentence. Thhe laast one iss alwaays morre dificult
+This is a sentence with one wrong word. This is a clean sentence. The last one is always more difficult
注意:最多 "without introduc[ing] confusing changes to the index"(# EDITING PATCHES)
不,git 帅哥的标准工具是使用线条(或附近的一组更改线条)。然而,git 所做的只是在三种状态中的每一种状态下对文件进行快照;因此,如果您有权访问您的更改,您可以轻松重播。首先,执行其中一项更改(然后执行提交),然后重播第二项更改(然后执行提交),依此类推。
尽管逐字逐句地执行此操作可能不值得 - 您最终会得到许多没有真正独立相关性的提交。
我希望从一个独特的提交中制作一个交互式补丁。我想使用类似于
的输出git diff --word-diff=porcelain [file]
用于交互式修补。命令
git add --edit
只推荐至少一行的帅哥?
目标:我有一个文本文件的补丁,我想像 "LibreOffice" 接受或拒绝更改那样进行更改。
示例:
一行文本文件:
echo "Thiis is a sentence with one wrong word. This is a clean sentence. Thhe laast one iss alwaays morre dificult" > text.txt
提交
git add text.txt
git commit -m "one"
修改文件
echo "This is a sentence with one wrong word. This is a clean sentence. The last one is always more difficult" > text.txt
git add -e
应该会自动剪成3块
"Thiis" > "This"
"Thhe laast" > "The last"
"iss alwaays morre dificult"> "is always more difficult"
刚好可以得到
--- a/text.txt
+++ b/text.txt
@@ -1 +1 @@
-Thiis is a sentence with one wrong word. This is a clean sentence. Thhe laast one iss alwaays morre dificult
+This is a sentence with one wrong word. This is a clean sentence. The last one is always more difficult
注意:最多 "without introduc[ing] confusing changes to the index"(# EDITING PATCHES)
不,git 帅哥的标准工具是使用线条(或附近的一组更改线条)。然而,git 所做的只是在三种状态中的每一种状态下对文件进行快照;因此,如果您有权访问您的更改,您可以轻松重播。首先,执行其中一项更改(然后执行提交),然后重播第二项更改(然后执行提交),依此类推。
尽管逐字逐句地执行此操作可能不值得 - 您最终会得到许多没有真正独立相关性的提交。