git 在调整缩进的问题
发布于 3年前 作者 guilin 1499 次浏览

调整缩进后,就会视作此行改变。有时会提示 rewrite, 但事实上,只是把一段代码从这里移动到了那里而已,不知道这个问题有没有一个好的解决方案。

2 回复

Everything in Git is check-summed before it is stored and is then referred to by that checksum. This means it’s impossible to change the contents of any file or directory without Git knowing about it. This functionality is built into Git at the lowest levels and is integral to its philosophy. ——摘自:http://progit.org/book/ch1-3.html

git 的设计思想决定了它要记录所有改变,所以我想应该没有方法让它对缩进的修改视而不见吧,不然就违反它的原则了。

不过在用 git diff 比较两个版本的差别时是有参数可以忽略仅修改了缩进的行的: -w 或 --ignore-all-space,使用时需要注意这个参数会同时忽略行中间的空白字符的改变,具体请查看 git help diff 提供的信息

回到顶部