Search code examples
gitgit-diff

How to use "git diff --minimal" algorithm when entering patch mode?


I have solely deleted a ton of lines in a really large file. When I stage and commit the changes to the file, Git's default diff algorithm thinks I've moved a bunch of things around instead of only deleting lines (the file has a lot of repetitive lines).

Here's my output from two different diff algorithms:

git diff --stat
1 file changed, 4373 insertions(+), 9192 deletions(-)

git diff --stat --minimal
1 file changed, 4819 deletions(-)

Is there a way that I can enter patch mode with the --minimal setting so that I can separate these into multiple commits for the purpose of reducing my perceived footprint on this file?

EDIT: Even after all of this effort to reduce my footprint, the diff across the multiple commits using the myers (default) algorithm still shows the insertions... I was hoping this would not happen, but now it seems that I have wasted a lot of time in exchange for learning something new about Git.


Solution

  • Apparently the patch mode uses your configured default diff algorithm. Updating my config with the following command gave me the desired results.

    git config --global diff.algorithm minimal