我可以修改git-add的默认** hunk大小吗? [英] Can I modify git-add's **default** hunk size?

查看:145
本文介绍了我可以修改git-add的默认** hunk大小吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆