git diff: ignore renaming of variables
While doing some refactoring, I renamed a variable from oldName
to newName
. Is there a way to tell the git diff
command to ignore differences where oldName
is now newName
? I want to do this to focus in on only the other non-trivial changes. If this is possible, can I also specify more than one variable renaming to ig开发者_Python百科nore, e.g., ignore changes from oldName1
to newName1
and from oldName2
to newName2
... ?
He is very correct, but of course you can grep the output of diff. Not the same thing, but depending on the magnitude of the change, perhaps usable.
git diff | egrep -v 'oldName|newName' | egrep '^[+-]'
In general, you should try to have your commits be one commit per concept. You can also split your pre-commits using git add -p
.
You want to use the -I option of diff? Here's a way how to do this:
env GIT_EXTERNAL_DIFF='perl -e "system(qw{diff -I the_pattern_to_ignore -u}, @ARGV[0,1])"' git diff
perl is needed here to throw away the extra arguments git provides to the external diff program.
OK. selckin in Git's IRC channel told me that it's not possible.
精彩评论