SourceTree App says uncommitted changes even for newly-cloned repository - what could be wrong?

后端 未结 5 2127
独厮守ぢ
独厮守ぢ 2020-12-04 14:23

A remote git repository is just cloned to a local box using Atlassian SourceTree. Even no files have really been modified in the work tree, Atlassian lists

5条回答
  •  执笔经年
    2020-12-04 14:57

    Normally this line in .gitattribute:

    * text=auto
    

    automatically ensures that all files that Git considers to be text will have normalized (LF) line endings in the repository, even when git config core.autocrlf is set to false (default). Therefore Git automatically changes the files according to these rules.

    So you've the following possibilities:

    • assume the normalization changes are correct (as far they're done to the text files) and simply commit them, e.g.

      $ git diff
      $ git commit -m "Introduce end-of-line normalization" -a
      
    • remove/disable auto normalization from the .gitattribute file and reset the files,

    • remove the index and re-scan the files, e.g.

      $ rm -v .git/index # Or: git rm --cached -r .
      $ git reset --hard # Rewrite the Git index. Or: git add -u
      
    • alternatively, whatever you do, try with force (-f), e.g. git pull origin -f, git checkout master -f, etc.,

    • use git command-line instead, since it could be a problem with SourceTree App it-self.

    See: Dealing with line endings at GitHub docs.

提交回复
热议问题