For example, performing a "Reformat Code" operation in an IDE such as IntelliJ may produce a lot of formatting changes to code. Subsequently when files are committed and diffs are viewed in Git and Stash the formatting changes in the diffs make the changes difficult to read.
Is there a way to tell Git or Stash to ignore formatting changes?
You can tell git to ignore whitespace changes (see the various --ignore-*
options in git diff --help
). If your reformatting is changing more than whitespace than it's really not possible for Git to tell the difference between a "reformatting" and a "legitimate change".
One option to deal with this sort of thing is to always run your code through a standard formatting tool when committing it to the repository. See, e.g., the "smudge" and "clean" attributes (and examples) described here. This way your code always has the canonical formatting.