How do I get Git Extensions to ignore whitespace in generating the commit list?

198 Views Asked by At

Background

I will start by noting that I do not know or understand Git very well at all.

I setup a Github repo for a small project I'm working on and managed it using Git Extensions. This worked fine for the last year, and helped me learn the basics of Git.

This past weekend I got a new SSD and reinstalled Windows and Git and Git Extensions. I told Git Extensions to open a repo and pointed it at my folder and it appeared to work, but it was not connected to GitHub at all. I'm guessing because the local and remote repos are different things and "opening" this local repo caused Git Extensions to see it only as a local repo.

My Workaround

Unfortunately, I forgot to commit before the Windows reinstall, so I have a large number of uncommitted changes locally. So my solution was to:

  1. Rename my "project" folder to "project bak"
  2. Clone the rep from gitHub into the "project" folder
  3. Copy everything from "project bak" to the "project" folder (except the "git" subfolder)

The Problem

This almost worked. However, now git Extensions shows that I have 294 changed files (essentially every single file). When I open the commit window and click a file to view it, the diff window shows almost the entire file. However, when I tap the "ignore whitespace changes at end of line" filter, the diff window is empty. I guess because the remote repo has some different whitespace or line return settings than my local.

This makes Git Extensions unusable for me; it's too hard to find the files that I actually changed in the list of 294 files. I want Git Extensions to work like it did before: show me the 10-20 files actually changed so I can easily select a group to commit with a description.

Solutions?

One solution that could have worked was to simply commit everything again with a message like "fixing whitespace". However, since I have a bunch of uncommitted local changes, and it would take hours to figure out where they all are with a manual compare, this won't work for me. This feels like a clunky solution anyway

It seems like the obvious solution is to change a setting somewhere in Git Extensions to tell it to "ignore whitespace", but I can't seem to find that anywhere.

I thought maybe Git Extensions just relies on Git to generate that list and tried searching Google for a way to tell Git to ignore whitespace, but no luck.

2

There are 2 best solutions below

0
Philippe On

You're eol problem should come from the git eol config that must not be the same than the previously one used.

Have a look at that to change it: https://git-extensions-documentation.readthedocs.io/en/release-4.0/settings.html#line-endings

But your best option is maybe to prefer the good practice to use a .gitattributes file to handle that once and for all: https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings#per-repository-settings

0
Yukii Liu On

According to my understanding, you may want to make the diff tool of git extension to ignore the "whitespace" modification. If you're using the GUI of git extension, you can open this diff interface at the top of the window like this. Then move your mouse to the diff window of your file, you will see these icons at the top of the window. Click this icon, it said "Ignore the amount of whitespace" like this. Then you can choose the rightmost "Setting" icon, tick the option "Git Extensions->Detailed->Diff Viewer->Remember the 'Ignore whitespace preference'" to make our modification always work. Hope my answer makes help for you.