Can't seem to discard changes in Git

后端 未结 20 1327
傲寒
傲寒 2020-11-29 21:17

After seeing the following from the command line:

# On branch RB_3.0.10
# Changed but not updated:
#   (use \"git add ...\" to update what will b         


        
20条回答
  •  离开以前
    2020-11-29 22:01

    It might be line endings, as @1800-information suggests, but another possibility is that the difference (that's preventing your from reverting these files with a checkout command) is one of file mode. This is what happened to me. On my version of git you can discover this by using

    git diff index.htm

    And it will show you file mode changes. It still won't let you revert them, though, using checkout, even with the -f option. For that use either

    git config core.filemode false

    or change your git .config in your text editor by adding

    [core]

    filemode = false
    

    After you do this, you can use

    git reset HEAD index.htm

    and the file should disappear.

    (I got all of this from the answers to How do I make git ignore mode changes (chmod)? and updating-file-permissions-only-in-git)

提交回复
热议问题