Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

git-diff

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.

like image 230
Cody Stott Avatar asked Jul 12 '26 23:07

Cody Stott


1 Answers

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

like image 194
Cody Stott Avatar answered Jul 15 '26 11:07

Cody Stott



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!