Skip to content

git status shows all files as modified #184

Closed

Description

@charlescho

I have some repos created in windows. When I run git status, it shows all files in the branch as up to date and nothing to commit except for a couple of untracked files. When I run git status, in bash on Ubuntu on Windows, it shows what seems to be all of my files as modified and not staged for commit.

Activity

  1. benhillis commented on Apr 14, 2016

    @benhillis
    Member

    Could you check if your git for windows version and git version inside bash are similar? It's possible that there is an incompatibility between the way the versions keep track of changes.

  2. charlescho commented on Apr 14, 2016

    @charlescho
    Author

    Ben Hillis (@benhillis) you might be right about that. In windows I have git version 2.7.2 installed, and in ubuntu on windows, I have version 2.8.1 installed. I guess this is not a big deal since I knew all my repos were up to date and I could do a git reset in bash on ubuntu on windows.

  3. benhillis commented on Apr 14, 2016

    @benhillis
    Member

    I'm speculating :)

    I'll try this as well and see what I find.

  4. denisw commented on Apr 14, 2016

    @denisw

    This could have something to do with WSL reporting the permissions of all files on the Windows filesystem as being 777. Git then regards all files as changed because their permissions are different.

    Try changing the Git configuration so that permission changes are ignored:

    # For the current repository
    git config core.filemode false   
    
    # Globally
    git config --global core.filemode false
    
  5. nestalk commented on Apr 14, 2016

    @nestalk

    It may be line endings,WSL thinks it is linux so it will use LF as the line endings.

    You can set git to only use CRLF line endings with:

    git config --global core.autocrlf true
    
  6. mjoppich commented on Apr 16, 2016

    @mjoppich

    I also think this might be line endings.

    I have the very same problem between the "git bash" (mingw) and cygwin ...

  7. russalex commented on Apr 27, 2016

    @russalex
    Contributor

    Older thread so wanted to clean up.

    Tried git config --global core.autocrlf true and it looked to clean up this issue.

    Marking this one as fixes for now. I'll close it out as a cleanup in about a week if no additional comments / discussions.

  8. asher-dev commented on Mar 20, 2017

    @asher-dev

    Just a follow-up to this, since I had the same issue and this thread helped me:

    The issue was only fixed when I changed the configuration for both core.autocrlf and core.filemode.
    That is (for the local repository),
    git config core.autocrlf true
    git config core.filemode false

    If I change either of them back to their original setting, every file in the repository is listed as modified.
    On another note, unless you're certain that you will only be cloning repositories on git for Windows, I don't recommend changing the --global setting.

  9. tdaniely commented on Jan 16, 2018

    @tdaniely

    I came across this today, setting both autocrlf=true & filemode=false both globally and in the repo config doesn't work. git status still shows all files as changed.

    git version 2.7.4
    UbuntuOnWindows version 1604.2017.922.0
    Ubuntu release is Ubuntu 16.04.3 LTS

    Repository was originally cloned with git-for-windows. where autocrlf is also true globally.
    Actual files on disk have CRLF.

  10. barkofdelight commented on Feb 1, 2018

    @barkofdelight

    Hi there.

    I am experiencing a similar problem, which might be part of your problem.

    git ls-files has a --debug flag which sheds some light on the matter.

    I make repository with a file and in the ubuntu bash script I issue that command, I get this output:

    test1
    ctime: 1517447477:356798400
    mtime: 1517447477:356798400
    dev: 12 ino: 212494
    uid: 0 gid: 0
    size: 14 flags: 0

    I run the same command on the Windows side (also using bash, but not via Ubuntu) and I get the same results. So far so good.

    But...after running git status on the Windows side, the numbers change!:

    test1
    ctime: 1517447474:553598100
    mtime: 1517447477:356798400
    dev: 0 ino: 0
    uid: 0 gid: 0
    size: 14 flags: 0

    This is a problem. This means that switching platforms invalidates entries in the index cache. This will trigger a re-stat of the invalid files, which will be slow. (In one of my cases, excruciatingly so.)

    But I know what you're thinking...an invalid cache should just be slow, not produce incorrect results. Yes I agree, but I still suspect this is part of the problem.

    History: I was tracking down a similar problem in git lfs (you can search for it and you'll see it numerous times) which has to do with what happens when a filter is changed (or the list of file types it acts upon gets changed). [Turns out this not specific to git lfs and can happen with any filter.]

    In that situation, this mattered. I was seeing changes on the platform which had the foreign index file. The files were in fact out-of-date. But on the other platform, this fact was hidden by the index matching, as the direct comparison was being skipped in that case.

    Hope this helps. Even if not, I hope somebody reading this might know more about this index-entry time difference and identify it as a bug or a limitation.

    Later.

  11. lqueryvg commented on Apr 8, 2018

    @lqueryvg

    I had this problem too. Sharing my problem and solution...

    Environment

    • Windows 7
    • VS Code 1.22.1

    Problem

    I had created a repo using cygwin git version 2.15.1 (I'm using cygwin because zsh is cool, ok?).
    Unfortunately, VS Code was picking up git for windows (git version 2.15.0.windows.1) which was reporting all files as modified.

    I tried configuring VS Code to pick up cygwin git instead, but they will not play nicely together (surprise surprise 🙄 ):
    microsoft/vscode#7998

    For me, all suggestions that this was caused by line endings were a red herring.

    Solution

    The solution was to modify .git/config in the repo to add the following option:

    [core]
            filemode = false
    

    This explanation was : helpful
    From now on, I'll configure my cygwin environment to use the same "git for windows" that VS code is using, since VS code is forcing me to go down that route.

    Epitaph

    Trying to get open source tools to work on Windows has always been a PITA. ~20 years of this nonsense, will it ever end ?

  12. syntholly commented on Oct 17, 2018

    @syntholly

    Just a minor update on an old issue.

    I work on a *nix box through SSH from my MacOS system. Git is updated through Homebrew and there is a mismatch on that version with the box's.

    To that end, I discovered that as long as both settings match, you'll find the issue resolves itself.

    For MacOS users, the following helped (on both the *nix box and my desktop):

    git config --global core.autocrlf false && git config --global core.filemode true

  13. luigip commented on Oct 17, 2018

    @luigip

    Git comes with Git Bash, which avoids this problem. It also has handy tab-completion, which you don't get in powershell.

  14. 11 remaining items

  15. heryudi commented on Jun 8, 2020

    @heryudi

    Older thread so wanted to clean up.

    Tried git config --global core.autocrlf true and it looked to clean up this issue.

    Marking this one as fixes for now. I'll close it out as a cleanup in about a week if no additional comments / discussions.

    Works for me as well. Thanks!

  16. Lolkekzor commented on Jun 15, 2020

    @Lolkekzor

    Fix worked, thanks.

  17. harindaka commented on Jun 18, 2020

    @harindaka

    If you are trying to trigger the git installation in windows from within WSL, then just use git.exe instead of just git. No additional git configuration needed

  18. cladmi commented on Jun 24, 2020

    @cladmi

    If you are trying to trigger the git installation in windows from within WSL, then just use git.exe instead of just git. No additional git configuration needed

    I am trying to look at a repository with git lfs files on the windows filesystem from WSL.
    With all the configurations said in this page the files are still shown as modified.

    Using git.exe for listing diff in wsl does not report the lfs tracked files as modified so helps workaround the issue mentioned by barkofdelight

  19. Chiramisudo commented on Jun 27, 2020

    @Chiramisudo

    See the official documentation for the correct way to resolve line endings conflicts using the .gitattributes file in Git 2.10+. This is the preferred method over setting core.autocrlf true because it goes into source control and resolves the issue for everyone using the repo whereas the git config method resolves the issue only for you.

    Sources:
    Get started using Git on Windows Subsystem for Linux / Git line endings | Microsoft Docs
    Resolving Git line ending issues in containers (resulting in many modified files) | VS Code
    Reference Page: .gitattributes | git-scm.com

  20. receter commented on Oct 27, 2020

    @receter

    See the official documentation for the correct way to resolve line endings conflicts using the .gitattributes file in Git 2.10+. This is the preferred method over setting core.autocrlf true because it goes into source control and resolves the issue for everyone using the repo whereas the git config method resolves the issue only for you.

    Sources:
    Get started using Git on Windows Subsystem for Linux / Git line endings | Microsoft Docs
    Resolving Git line ending issues in containers (resulting in many modified files) | VS Code
    Reference Page: .gitattributes | git-scm.com

    Thanks, this is by far the best solution for the line ending issue.

  21. kantmichel commented on Dec 22, 2020

    @kantmichel

    For me it had something to do with source control inside VScode. Instead of git add . inside powershell I managed the commit inside of VS code. This actually removed the list of all hundreds of files for me.

  22. cyancity commented on Jan 22, 2021

    @cyancity

    same situation here, problem solved

  23. Prakash-seh commented on Jul 2, 2021

    @Prakash-seh

    This could have something to do with WSL reporting the permissions of all files on the Windows filesystem as being 777. Git then regards all files as changed because their permissions are different.

    Try changing the Git configuration so that permission changes are ignored:

    # For the current repository
    git config core.filemode false   
    
    # Globally
    git config --global core.filemode false
    

    After surfing internet for 30 min, I'm finally able to get it right all thanks to u Sir

  24. benfulton commented on Apr 7, 2022

    @benfulton

    @mattdamon108 yeah, unfortunately, git overrides this setting every time you clone a repo for whatever reason the global setting does nothing unless you remove it locally.

    This is what I had to do. git config --global core.fileMode false did nothing, while git config core.fileMode false fixed the issue.

  25. paddy-r commented on Dec 20, 2022

    @paddy-r

    Just a follow-up to this, since I had the same issue and this thread helped me:

    The issue was only fixed when I changed the configuration for both core.autocrlf and core.filemode. That is (for the local repository), git config core.autocrlf true git config core.filemode false

    If I change either of them back to their original setting, every file in the repository is listed as modified. On another note, unless you're certain that you will only be cloning repositories on git for Windows, I don't recommend changing the --global setting.

    This did it for me (working in Windows with a repo developed in Linux), and only requires local change to settings.

  26. paddy-r commented on Mar 22, 2023

    @paddy-r

    This could have something to do with WSL reporting the permissions of all files on the Windows filesystem as being 777. Git then regards all files as changed because their permissions are different.

    Try changing the Git configuration so that permission changes are ignored:

    # For the current repository
    git config core.filemode false   
    
    # Globally
    git config --global core.filemode false
    

    Denis Washington (@denisw) The first command fixed it for me, thanks, followed by a git reset. The file permissions had indeed been changed by Windows when I copied and pasted a repository. (Lazy, I know, but wanted to avoid re-cloning!)

  27. fistvan commented on Dec 5, 2023

    @fistvan

    If the above config settings don't seem to work, you can always check the full configuration parameter list with
    git config --list

  28. sadmananik commented on Dec 12, 2023

    @sadmananik

    In my case, this was happening due to file permissions, so I had to run the following command for that file:

    git update-index <file>

  29. Clumsy-Coder commented on Mar 6, 2024

    @Clumsy-Coder

    I found that running command git update-index --assume-unchanged $(git ls-files | tr '\n' ' ') helps.

    obtained from

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions