3

All my files become unstaged in Git, when using Ubuntu.

When I run git diff, Git shows:

--- a/<filename>
+++ b/<filename>
-<output of file>
+<output of file>

For example,

--- a/.gitignore
+++ b/.gitignore
-.tmp
-build
-node_modules
+.tmp
+build
+node_modules

However, when I use Git in Windows, Git properly shows the status (all files committed and staged)

Any ideas of how to fix this?

I'm using the same partition with the Git repo in both Ubuntu and Windows, and since it is in FAT32, Ubuntu automatically mounts the partition.

user705179
  • 73
  • 4

1 Answers1

3

This sounds like a CRLF issue. Windows uses CRLF to denote end-of-line while Linux uses just LF. Git uses just LF natively. When you switch from Windows to Linux, git sees the files as changed because it doesn't think it has to convert the CRLF that ends every line to LF and thus the files get extra CR characters.

See this blog post on the subject for an extensive discussion.

This is all controlled by the core.eol config option. Typically, this is set to native, which tells git to use your OSes EOL convention. Your best bet is to create a .gitattributes file as the post specifies, telling get to use LF regardless of the OS.

Gort the Robot
  • 2,329
  • 16
  • 21