gpt4 book ai didi

git 暂存补丁 : with hunk smaller than a line

转载 作者:太空狗 更新时间:2023-10-29 13:14:24 26 4
gpt4 key购买 nike

我希望从一个独特的提交中制作一个交互式补丁。我想使用类似于

的输出
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

promise

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 block

"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" (# 编辑补丁)

最佳答案

不,git hunks 的标准工具是使用线(或附近的一组更改线)。然而,git 所做的只是在三种状态中的每一种状态下对文件进行快照;因此,如果您有权访问您的更改,您可以轻松重播。首先,执行其中一项更改(然后执行提交),然后重播第二项更改(然后执行提交),依此类推。

虽然逐字逐句地执行此操作可能不值得 - 您最终会得到许多没有真正独立相关性的提交。

关于git 暂存补丁 : with hunk smaller than a line,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31230949/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com