git status shows modifications even with autocrlf=false

后端 未结 6 1595
终归单人心
终归单人心 2020-11-30 03:21

I\'m experiencing the same issues as in this question: git status shows modifications, git checkout -- doesn't remove them

Git continues to show wor

相关标签:
6条回答
  • 2020-11-30 03:34

    Although i don't know what is causing this weird behaviour, i know one more way of discarding changes that might work.

    Warning! Be extremely careful and do a backup first; this can be highly destructive.

    If all data that you care about is committed in the repository, you can simply delete everything in your working directory (of course except hidden .git directory) and run git reset --hard HEAD to have git recreate the working directory solely from the repository data.

    Remember to carefully check if you don't have any important data that is not tracked by git before doing this. It's not enough to check git status for uncommitted changes - remember that deleting all files from the working dir will also delete files which you told git to ignore, and they won't be recreated with git reset --hard HEAD because they're not tracked at all.

    0 讨论(0)
  • 2020-11-30 03:43

    Check if you have no .gitattributes file

    As mentioned in the "Effect" section of the gitattributes man page, those files can also have an effect on eol and automatic transformation:

    text ^^^^^^
    

    This attribute enables and controls end-of-line normalization.
    When a text file is normalized, its line endings are converted to LF in the repository.
    To control what line ending style is used in the working directory, use the eol attribute for a single file and the core.eol configuration variable for all text files.

    Check also your config for core.eol, as mentioned in "How line ending conversions work with git core.autocrlf between different operating systems".

    0 讨论(0)
  • 2020-11-30 03:47

    This problem can be caused by gitattributes' text option.

    Please read the documentation carefully but essentially autocrlf only matters if text is not set in a .gitattributes:

    Unspecified
    If the text attribute is unspecified, git uses the core.autocrlf configuration variable to determine if the file should be converted.

    Find your .gitattributes file via:

    find <root-dir> -name .gitattributes
    

    And grep for text, eol or crlf to find your culprit and revise as necessary.

    You may just change this file and revert the change without committing for long enough to get through your issue.

    0 讨论(0)
  • 2020-11-30 03:47

    "autocrlf" issue is a typical issue for cross multi platform repo (i.e. using a samba share with tortoisegit over a server under linux)

    I realized, that sometimes (often), it's more a "chmod" issue than a autocrlf one : - git status windows display pending modifications - git status linux display nothing

    "mode change 100755 => 100644 config/packager.xml"

    Check that your "static" files are not +x, (and in this case tortoisegit wont like it)

    0 讨论(0)
  • 2020-11-30 03:50

    I'm investigating the weird behavior of core.autocrlf in MSysGit, and I found that having:

    [core]
        autocrlf = false
        safecrlf = true
        ignorecase = true
        eol = native 
    

    in the global config file and NO core.autocrlf setting in a repo copied from another PC (not cloned, only copied), issuing a git status command results in ALL text files marked as modified (no gitattributes around).

    But if you add a local (repository) core.autocrlf setting to true, and then issue a git status command, all the changes disappears and the repository turns back to be clean.

    BUT (and this is the strange behavior) if you remove the just added core.autocrlf setting from the repository config file (thus returning to the exact initial state), the git status command continues to report no changes!

    Given that no operations has been performed on the repository, only changing a config setting, and reverting back to the original state, has done the trick...

    If this isn't a bug, I can't imagine who in the world can call this a "normal" behavior.

    0 讨论(0)
  • 2020-11-30 03:51

    This seems like a bug in msysgit indeed. As a workaround, try creating a .gitattributes file containing

    * -text
    

    This will tell git not to perform EOL conversions on any files.

    0 讨论(0)
提交回复
热议问题