Search code examples
gitdiffgitignore

gnudiff, and .gitignore files


To be clear - This is not a git diff problem or question

I have two locally checked out repos - that share a common quasi common heritage.

Both are under git control (but come from two separate remote servers) - they have many things in common.

What I would like to do is a normal gnu diff -Naur type comparison between the two directory structures.

Normally you would use --exclude=PATTERN options for gnu-diff to exclude things. For example you might --exclude=.git to ignore the two different .git directories

What I want instead is an option to make gnu-diff .gitignore aware

in effect, as gnu diff traverses the directory structure and comes across a .gitignore file follow the GIT rules and ignore accordingly.

Sort of an option like this:

diff -Naur  --honor-git-ignore-files  DIR1   DIR2

Solution

  • Since there does not seem to be a default linux diff option like the one you mention, you could: