git status 显示修改,git checkout -- <file> 不删除它们

标签 git revert git-status working-copy

我想删除对我的工作副本的所有更改。
运行 git status 显示修改的文件。
我所做的一切似乎都无法删除这些修改。
例如:

rbellamy@PROMETHEUS /d/Development/rhino-etl (master)
$ git status
# On branch master
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       modified:   Rhino.Etl.Core/Enumerables/CachingEnumerable.cs
#       modified:   Rhino.Etl.Core/Pipelines/SingleThreadedPipelineExecuter.cs
#       modified:   Rhino.Etl.Tests/Rhino.Etl.Tests.csproj
#       modified:   Rhino.Etl.Tests/SingleThreadedPipelineExecuterTest.cs
#
no changes added to commit (use "git add" and/or "git commit -a")

rbellamy@PROMETHEUS /d/Development/rhino-etl (master)
$ git checkout -- Rhino.Etl.Core/Enumerables/CachingEnumerable.cs

rbellamy@PROMETHEUS /d/Development/rhino-etl (master)
$ git status
# On branch master
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       modified:   Rhino.Etl.Core/Enumerables/CachingEnumerable.cs
#       modified:   Rhino.Etl.Core/Pipelines/SingleThreadedPipelineExecuter.cs
#       modified:   Rhino.Etl.Tests/Rhino.Etl.Tests.csproj
#       modified:   Rhino.Etl.Tests/SingleThreadedPipelineExecuterTest.cs
#
no changes added to commit (use "git add" and/or "git commit -a")

rbellamy@PROMETHEUS /d/Development/rhino-etl (master)
$ git checkout `git ls-files -m`

rbellamy@PROMETHEUS /d/Development/rhino-etl (master)
$ git status
# On branch master
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       modified:   Rhino.Etl.Core/Enumerables/CachingEnumerable.cs
#       modified:   Rhino.Etl.Core/Pipelines/SingleThreadedPipelineExecuter.cs
#       modified:   Rhino.Etl.Tests/Rhino.Etl.Tests.csproj
#       modified:   Rhino.Etl.Tests/SingleThreadedPipelineExecuterTest.cs
#
no changes added to commit (use "git add" and/or "git commit -a")

rbellamy@PROMETHEUS /d/Development/rhino-etl (master)
$ git reset --hard HEAD
HEAD is now at 6c857e7 boo libraries updated to 2.0.9.2 and rhino.dsl.dll updated.

rbellamy@PROMETHEUS /d/Development/rhino-etl (master)
$ git status
# On branch master
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       modified:   Rhino.Etl.Core/Enumerables/CachingEnumerable.cs
#       modified:   Rhino.Etl.Core/Pipelines/SingleThreadedPipelineExecuter.cs
#       modified:   Rhino.Etl.Tests/Rhino.Etl.Tests.csproj
#       modified:   Rhino.Etl.Tests/SingleThreadedPipelineExecuterTest.cs
#
no changes added to commit (use "git add" and/or "git commit -a")

最佳答案

我在 Windows 上遇到了这个问题,但不准备研究使用 config --global core.autocrlf false 的后果我也不准备放弃其他私有(private)分支和好东西在我的藏品中,从一个新的克隆开始。我只需要完成一些事情。现在。

这对我有用,因为你让 git 完全重写你的工作目录:

git rm --cached -r .
git reset --hard

(请注意,仅运行 git reset --hard 还不够好,在 reset 之前对文件执行简单的 rm 也不够好正如对原始问题的评论中所建议的那样)

关于git status 显示修改,git checkout -- <file> 不删除它们,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2016404/

相关文章:

Git SVN 区分大小写的文件夹名称

git - 撤消 git merge (尚未推送)

Eclipse 会在按键时恢复对文件的所有更改,无法撤消?

git - 将旧的 git commit merge 到当前分支的顶部

Git 推送到 heroku

css - heroku 和 django : server doesn't load staticfiles

git:gitcherry-pick后gitcherry的输出没有改变

git - 是否有可能 `git status` 只有修改过的文件?

git-status - 编辑并提交到本地存储库后,Git 状态不显示 'ahead of'

libgit2sharp - 标记为 'Deleted' 的文件在 LibGit2Sharp 中报告为 'Missing'