'Local Changes' window shows diffs when checkout to a git branch other than master
Answered
I'm using Intellij 14.1.4 and with projects in git/stash.
If I clone a repo and checkout on the master branch then open a new project in IDEA, all is well. The 'Local Changes' window shows no diff.
Following checkout of a different branch, the 'Local Changes' window suddenly lists multiple files that have changed between master and the specific branch. However, there are no local changes to these files. If I perform a file diff, the diff tool indicates the files are identical.
What does the 'Local Changes' window perform the diff against? Is it possible that it always performs the diff against the master branch rather than the currently checked out branch? Is this configurable?
Please sign in to leave a comment.
Most likely these are changes to line endings. Files in git repository are saved with LF, while in the working directory the have something different.
This often happens on Windows.
What is set for the git config core.autocrlf?
Currently core.autocrlf has no setting so it takes it's default value.
Just to clarify, the diff tool shows the contents are identical. It would indicate if the files had different line endings but this is not the case.
Also, not all files show up in the 'Local Changes' window, it looks like it's only those that changed between master and the checked out branch.
> it takes it's default value
Are you on WIndows?
> It would indicate if the files had different line endings
There are reports when it does not - see https://youtrack.jetbrains.com/issue/IDEA-175120
Check the `git diff` in the command line. Seems exactly line endings conversion, since it affects only checked out files (files that are not changed between branches are not updated in the working tree)
Yes Windows. The files have LF as the line ending in master and branch.
The command line git diff shows no differences. Command line git status shows no modified files.
The Intellij diff tool would indicate if there were line ending differences
e.g. Manually changing the line ending for demonstration
However, this is not the case.
Ok, so the issue is that IDE shows changes while git status doesn't?
Does the Refresh in the local changes help?
How is the git root mapped in Settings - Version Control? If there is <Project> mapping there, try changing to the explicit project path.
>Ok, so the issue is that IDE shows changes while git status doesn't?
No, the issue is that the Local Changes window indicates changes where there are no changes.
>Does the Refresh in the local changes help?
No
>How is the git root mapped in Settings - Version Control? If there is <Project> mapping there, try changing to the explicit project path.
I tried both settings, it doesn't work.
However, I have made a minor breakthrough. I have been cloning the code using git from cygwin command line. I have discovered that if I clone from within IntelliJ the issue does not appear. Turns out the version of Git used by Intellij is different to that used within cygwin. I cannot explain why at the moment this appears to be the issue.
My cygwin installation comes with git version 2.15.0, Intellij uses git version 1.9.5.msysgit.1.
If I use git version 1.9.5(Used by Intellij) from the cygwin command line to clone a project and then open the project in Intellij, the issue does not occur.
Naturally the different versions of cygwin also come with different configuration.
2.1.50(cygwin)
http.sslverify=false
core.preloadindex=true
core.fscache=true
gc.auto=256
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.symlinks=false
core.ignorecase=true
core.hidedotfiles=dotGitOnly
1.9.5(Intellij)
core.symlinks=false
core.autocrlf=false
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
pack.packsizelimit=2g
help.format=html
http.sslcainfo=/bin/curl-ca-bundle.crt
sendemail.smtpserver=/bin/msmtp.exe
diff.astextplain.textconv=astextplain
rebase.autosquash=true
http.sslverify=false
Could actually be - caused by core.filemodetracking.
Just configure IDE to use the cygwin git executable (2.1.5.0) - and the issue should be solved, cause IDE should show exactly the same as git status.
As suggested I configured Intellij to use cygwin git executable.
That has resolved it. :-)
Many thanks for your assistance with this.