Can I make git diff ignore permission changes

血红的双手。 提交于 2019-11-28 03:26:40

This is an old question, and the answer is already in the comments but:

Use the -G<regex> option ("Look for differences whose patch text contains added/removed lines that match <regex>.") searching for any changes at all - i.e. .. Permissions-only changes don't match this, so they are ignored.

So: git diff -G.

This will tell git to ignore permissions:

git config core.filemode false

I had this problem after intentionally removing the execute permission from source code files (~26K files). Then, git diff says that all files have changed! The answer with core.filemode does not help me since that only affects diffs against your working dir, not diffs against 2 commits in the repo.

The answer was to use the (big scary) filter-branch command. In particular, all you need to type is:

git filter-branch -f --tree-filter 'find * -type f | xargs chmod 644 ' -- --all

from the root of your working dir. Of course, be sure to make a copy of your repo first (cp -pr ~/repo.git ~/repo-orig.git or similar), in case you need to re-try.

Enjoy!

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