You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Using git in Ubuntu Bash does not Sync with Native Windows git #1352
When executing git status inside Ubuntu Bash on Windows, it lists many files incorrectly. A git pull on an up-to-date repo can fail with collisions.
To reproduce:
Using a native windows git (e.g. in GitBash):
$ git clone https://github.com/Microsoft/BashOnWindows.git
Cloning into 'BashOnWindows'...
remote: Counting objects: 109, done.
remote: Total 109 (delta 0), reused 0 (delta 0), pack-reused 1Recei09
Receiving objects: 100% (109/109), 18.02 KiB | 0 bytes/s, done.
Resolving deltas: 100% (35/35), done.
Checking connectivity... done.
Guyon@Toruk MINGW64 /e/dev/git
$ cd BashOnWindows/
Guyon@Toruk MINGW64 /e/dev/git/BashOnWindows (master)
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
Start Ubuntu Bash on Windows and navigate to the repo directory
guyon@TORUK:/mnt/e/dev/git/BashOnWindows$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: CONTRIBUTING.md
modified: ISSUE_TEMPLATE.md
modified: README.md
no changes added to commit (use "git add" and/or "git commit -a")
Expected Result
There should be no modified files
Actual Result
There are modified files
My Windows Build Number: Version 1607 (OS Build 14393.447)
Hi Guyon Roche (@guyonroche) -- if you type git config core.autocrlf at the two different git prompts, do you get the same value at each, or is it different?
Windows and Linux represent newlines in text files differently. So, text files checked out on Windows will, by default, deliberately look different on disk than text files checked out on Linux. My guess is that what you're seeing here is Linux-git reporting that the files have been modified. It doesn't know that you have Windows-git installed and that Windows-git made this change. Even if it did know that, other Linux tools would not, so from their perspective this would also be a change.
If you have a single checkout that you want to share between Windows and Linux, my recommendation would be that you reinstall Windows git and, when prompted during installation, tell it to not modify newlines. (The default is to automatically convert them on checkout and convert them back on checkin.) Most Windows programs (with the notable exception of notepad.exe) can handle Linux newlines just fine, so this shouldn't affect your workflow.
in the Ubuntu bash. I guess no setting at all defaults to false. Now it ignores the \r\n differences
Reacted by Geraint Ballinger, Michael, Kristian Barrese, Apara Venkat, Amor, Michael Richardson, lani-cb, Ron Weisgross, Matej Kopcik, rohitkrishna094 and 12 more
Reacted by yao, FrozenSoda, Kene Okoye, 👻, Juan-Carlos Sreng-Flores, Manish Shrestha, Victor Nice, Luis Gustavo and Sheila
Sorry for bumping this thread. But just a small note, you could do
git config --global core.autocrlf true on ubuntu bash. This way you don't have to do this for every local repo.
Let me know if anyone finds a problem doing this, that is if it breaks anything. Thanks
Reacted by Chad Grant, yao, Andrew Poole, Muhammad Rafiul Ilmi Syarifudin, colayare, Tyler, Tony Ranieri, Andres Jácome, Sarang, Hector Tran and 9 more
Reacted by Nelwin Catalogo, Tony Ranieri, RuanBuitendag42, 👻, Juan-Carlos Sreng-Flores, wett1988, Aaron Leopold, Jacob R Epifano, Luis Gustavo and Sheila
Activity
aseering commentedon Nov 12, 2016
Hi Guyon Roche (@guyonroche) -- if you type
git config core.autocrlfat the two different git prompts, do you get the same value at each, or is it different?Windows and Linux represent newlines in text files differently. So, text files checked out on Windows will, by default, deliberately look different on disk than text files checked out on Linux. My guess is that what you're seeing here is Linux-git reporting that the files have been modified. It doesn't know that you have Windows-git installed and that Windows-git made this change. Even if it did know that, other Linux tools would not, so from their perspective this would also be a change.
If you have a single checkout that you want to share between Windows and Linux, my recommendation would be that you reinstall Windows git and, when prompted during installation, tell it to not modify newlines. (The default is to automatically convert them on checkout and convert them back on checkin.) Most Windows programs (with the notable exception of
notepad.exe) can handle Linux newlines just fine, so this shouldn't affect your workflow.Herst commentedon Nov 12, 2016
Maybe also has to do with file modes?
guyonroche commentedon Nov 13, 2016
Interesting, running git config core.autocrlf - in Gitbash I get an output of "true". In Ubuntu bash I get no output
guyonroche commentedon Nov 15, 2016
Herst - file modes looks likely...
In Gitbash:
In Ubuntu bash (same file):
Are there any workarounds for this?
Herst commentedon Nov 15, 2016
The
core.fileModesetting ofgit(rungit config core.fileMode false).guyonroche commentedon Nov 16, 2016
Found it - I ran:
in the Ubuntu bash. I guess no setting at all defaults to false. Now it ignores the \r\n differences
rohitkrishna094 commentedon Nov 22, 2019
Sorry for bumping this thread. But just a small note, you could do
git config --global core.autocrlf trueon ubuntu bash. This way you don't have to do this for every local repo.Let me know if anyone finds a problem doing this, that is if it breaks anything. Thanks