1

I'm currentely working on a Git pull request for some repository. I have run through typical steps: fork -> add some changes -> commit -> push to forked repo and then create a PR.

I'm quite familiar with Git and have already created many PRs, but a particular project starts to cause some formatting issues.

When I pushed the update branch and went to github UI to check my PR changes, I have see many many diff changes that seems related to Intellij IDEA which formatted my code. Here goes a sample: enter image description here

What those sections refer to? Why is Intellij removing an are and adding absolutely the same one so it is marked as a diff?

Actually those changes makes my PR too hard to read, even for me and I'm sure that project owner won't accept such an horor.

So my question is, how to deal with such situations? Can I disable code formatting and work on my PR? Is there an other hint to do so?

I'm addressing my question to Intellij + Git experts, so please suggest if there is some practices (good) I should follow.

Regards.

tmarwen
  • 15,750
  • 5
  • 43
  • 62
  • A lot of tools offer an option to ignore whitespace changes. This can be activated to be able to concentrate on substantial changes. I would review all whitespace changes at least superficially though. – musiKk Aug 29 '14 at 14:42
  • Can you list one of those tools? This seems too hazardous for me because I worked on a lot of PRs before and have never met such an issue as I always managed to adjust my ide inetation rules to much those for the repo I will commit to. – tmarwen Aug 29 '14 at 14:49
  • I'm sure IDEA can. Other than that: gitk, meld, Eclipse and a lot of git commands accept the `-w` option to accomplish that. But I think I misread your question; these options are useful for the person merging the pull request. Your question is more suited for an IDEA expert. – musiKk Aug 29 '14 at 14:59
  • Just what I thought, my issue should be considered from a developer view not the commiter one. Thanks for mentionning some of those options :) – tmarwen Aug 29 '14 at 15:02

1 Answers1

1

Actually, this is not an IDE issue, so Intellij IDE had nothing to do with it. The problem was actually due to how Git handled line endings.

Following some SO posts and tried multiple solutions, I ended up with @VonC suggestion to disable line endings modifications and where he stated:

I would insist on not trying to convert anything automagically, the side-effects are just too important (in term of potential merging conflict, especially on distributed development with different environments)

So simply executing below command will prevent Git from changing anything:

git config --global core.autocrlf false

Then had to clean (I have chosen to grab the remote branch again to start all from scratch and with a clean working copy) my working directory.

Community
  • 1
  • 1
tmarwen
  • 15,750
  • 5
  • 43
  • 62