How can I discard modified files?

后端 未结 10 741
甜味超标
甜味超标 2020-12-13 18:00

This is a Linux 2.6 kernel repository. I git clone it to my local host.

After that. I didn\'t make any change. But when I \"git status\". I found 13 modified files.

相关标签:
10条回答
  • 2020-12-13 18:31

    this problem was caused, for me, by a non-case-sensitive filesystem (e.g. on Mac OS). You can either create a case-sensitive disk image and mount it and do your git work on there, or use a different OS to do your development.

    0 讨论(0)
  • 2020-12-13 18:33

    If you would like to remove all the files and modifications that differ from your origin branch but would like to keep all the ignored files (ex. node_modules, .vscode, .idea etc..) the best choice is to combine these two commands:

     git reset --hard && git clean -f
    

    This will reset all modified files and will clean all the unstaged ones.

    0 讨论(0)
  • 2020-12-13 18:34

    A git reset --hard HEAD should solve the problem.

    0 讨论(0)
  • 2020-12-13 18:34

    There's another possibility where the issue is filemode-related. In that case you may try git config core.filemode false

    More info: How do I make Git ignore file mode (chmod) changes?

    Edit:

    Another possibility would be the line endings, try setting git config core.autocrlf true|false|input and see if it makes any difference.

    More info: Why should I use core.autocrlf=true in Git?

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