Can I modify git-add's **default** hunk size?

亡梦爱人 提交于 2019-11-30 13:27:00

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.

Update (2018-11-01)

If you're just interested in changing the default hunk size in the output of git diff, you can set it in your .gitconfig file by using the diff.context setting:

git config --global diff.context 0

Interestingly, you can also configure the number of lines to include between hunks with the diff.interHunkContext setting:

git config --global diff.interHunkContext 0

Setting it to 0 will effectively concatenate the hunks one after the other.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!