Strange Git Commit Behavior.
Doing actual commits from within Intellij seems to screw with line endings in unexpected ways.
I have repo on github that I am collaborating with- so I fork and branch to address an open ticket.
Do the fixes, make the commit- the diff viewer in Intellij indicates file changes accurately.
Push the branch-- issue a pull request and it shows the dreaded "every line changed" merge issue. I've tried hard changing the LF to CRLF in the IDE- I've made sure that the actual git global settings are using autocrlf (This is a windows machine btw).
Okay- fast forward to after I have been pulling my hair out in chunks:
I finally figure out the following things:
a) If I perform the actual commit from the command line (Powershell)- then github recognizes the file changes properly. I can do everything else from intellij- but using the commit function.
b) If I perform a commit using intellij and mess up the line endings- if I make a small change to a file that has already had changes committed using the IDE- and I then "recommit" the file using the command line- the file does not recover and the pull request shows that the entire file has changed.
What's going on here? Isn't intellij's commit function just wrapping git on the command line?
Help please!
Please sign in to leave a comment.
> Isn't intellij's commit function just wrapping git on the command line?
Yes, it is, but since 2018.3, it first stages the changes and then calls git commit, instead of using git commit --only, and there is a difference in line endings handling between these two approaches.
If you are committing changes partially, it could be https://youtrack.jetbrains.com/issue/IDEA-192771 Otherwise, it could be caused by automatic conversion in git, if e.g. files in the repository are saved with CRLF endings.
Please check the commands IDE executes in the Console tab of Version Control toolwindow, and try executing the same in the command line.
The issue appears to be a bug in git that treats git add --ignore-errors as git add --renormalize
https://youtrack.jetbrains.com/issue/IDEA-205601