无法使用Git将文件重置为特定的提交 [英] Can't reset a file to a specific commit using Git
问题描述
我有一个修改后的文件,我想要修改最新的提交中的任何内容,但它会卡住 $ git status
#在分支大师
#已更改但未更新:
#(使用git add< file> ...来更新提交)
#(使用git checkout - < file> ...放弃工作目录中的更改)
#
#修改:index.php
#
没有更改添加到提交(使用git add和/或git commit -a)
然后我试试:
$ git checkout - index.php
但git状态的输出仍然相同。然后我尝试:
$ git reset --hard master
HEAD现在在02c9613 test commit message
并且git状态的输出仍然是相同的。
关于如何摆脱对该文件的假定更改的任何想法?
您可能会遇到<一个href =http://www.google.nl/search?q=git+ignore+whitespace =nofollow>空白问题尝试 git config --global apply。 whitespace nowarn
。 如果这不起作用,我会说你遇到了一个bug。保存本地克隆以供将来参考(我希望它不是太大)并创建一个错误报告。特别是以下事实:
表明它可能不是你在这里犯了错误。您是否可以在干净的回购中重现问题也是有趣的信息。
I have a modified file which I want to rever to whatever is in the latest commit but it's "stuck" there always being marked as modified.
$ 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: index.php
#
no changes added to commit (use "git add" and/or "git commit -a")
I then try:
$git checkout -- index.php
But the output of git status is still the same. I then try:
$git reset --hard master
HEAD is now at 02c9613 test commit message
And the output of git status is STILL the same.
Any ideas on how I can get rid of the supposed changes on that file?
You might be running into a whitespace issue try git config --global apply.whitespace nowarn
for that.
If that doesn't work, I'd say you've run into a bug. Save the local clone for future reference (I hope it's not too big) and create a bug report. Especially the facts that:
- you haven't modified the file yourself
- other files don't show this problem
are signs that it might just not be you that made the mistake here. Whether you can reproduce the problem on a clean repo would be interesting information too.
这篇关于无法使用Git将文件重置为特定的提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!