3

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.

2
  • Maybe it's possible, maybe not. As a fallback method, you could stash these changes and manually replay the subsets of changes that you want to commit. Commented Oct 28, 2015 at 15:46
  • I was considering that, but the only inconvenient thing about that is I would get conflicts each time I applied the stash; and as a whole, these line deletions are not contiguous at all. Commented Oct 28, 2015 at 16:24

1 Answer 1

4

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.