Michael Wilson
Michael Wilson

Reputation: 1579

Lines are being added which weren't made

I'm having a wierd issue when using Git with Atom.

If I edit a few characters in a string, it actually ends up saying the change is something like: +131, -131. When I check the lines changed in SourceTree, its adding a load of spaces which wasn't done.

Here is the file without any changes done yet:

enter image description here

Here is the file with a change that isn't saved yet:

enter image description here

Now when I've hit saved:

enter image description here

You can see at first only one line was highlighted as being changed, but when I hit save - a load of other lines have appeared to change.

This is annoying because when I go to commit my changes, its not a true representation of what I've changed.

enter image description here

What could I be doing wrong here?

Upvotes: 1

Views: 45

Answers (1)

user743382
user743382

Reputation:

The default setting for Atom is to remove any trailing whitespace you may have had. This is a sensible default for new files where it prevents exactly the confusion you're seeing now. For existing files, it's a bit problematic, since the first time you edit an existing file, you'll see a lot of changes.

You can either accept this setting, preferably cleaning your whole repository in a single commit, and continuing from there, or you can disable the whitespace removal: in Edit, Preferences, Packages, Whitespace, Settings, Remove Trailing Whitespace can be unchecked.

Upvotes: 3

Related Questions