I would like to ignore certain changes when using git diff (such as version changes). I tried using the -G flag, but it doesn’t seem to work as expected. I also saw a reference to a regex in this question, but that doesn't seem to help.
I am hoping to do something like this:
git diff <hash> --unified=0 -G "^.*\<version\>.*"
I would expect this to include anything with <version> in it, but that doesn't happen. It seems to not seem to make any difference. I'd like to invert the -G if possible, but as a first step to get a basic regex working.
When you want to temporarily ignore changes, when you want to do a diff or a blame without seeing those changes, you can use a "textconv" filter that normalizes the text you diff. I use those to do things like strip embedded timestamps out of generated html when diffing, quickest to hand atm is
[diff "doc-html"]
textconv = "sed 's,<span class=\"version\">Factorio [0-9.]*</span>,,;s,<[^/>][^>]*>,\\n&,g'"
wordRegex = "<[^>]*\\>|[^< \\t\\n]*"
in .git/config, and
doc-html/*.html diff=doc-html
*.cfg -diff
in .git/info/attributes.
so my what-changed diffs don't show me things I don't care about.
If you want to see the results of a diff ignoring case, try
[diff "nocase"]
textconv="tr A-Z a-z"
and drop * diff=nocase (or maybe*.vba diff=nocase) into .git/info/attributes. When you're done, take it out.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With