我可以修改git-add的默认** hunk大小吗? [英] Can I modify git-add's **default** hunk size?
问题描述
git add -p
,可以选择对文件进行分段更改。 可以手动更改大块大小(我可以修改git-add的大块大小吗? ),但我想知道如何更改默认 hunk大小(例如,以单行)。
GIT_DIFF_OPTS
环境变量告诉Git多少每次需要 hunk 时,在你的情况下,你会说:
export GIT_DIFF_OPTS = -u0
其中 -u0
选项(短版 - 统一
)在每个大块中放置 0行,这有效地减少了它只包含已经改变的行。
Using git add -p
, one can select changes to a file for staging.
One can manually change the hunk size (Can I modify git-add's hunk size?), but I would like to know how to change the default hunk size (for example to a single line).
You can use the GIT_DIFF_OPTS
environment variable to tell Git how many lines of context it should include in a hunk every time it has to generate a patch.
In your case, you would say:
export GIT_DIFF_OPTS=-u0
where the -u0
option (the short version of --unified
) puts 0 lines of context in each hunk, which effectively reduces it to only contain the lines that have changed.
这篇关于我可以修改git-add的默认** hunk大小吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!