我正在运行安装了Git-1.8.3-preview20130601.exe
的Windows 7。
我在我的工作目录中有一个修改过的文件,我想把它恢复到上次提交时的状态。我尝试使用各种不同的git checkout
命令,但是修改后的文件仍然存在于我的工作目录中。例如:
[C:\Work\BitBucket\proj1] 14:32:45>git status
On branch work2
Your branch is behind 'origin/work2' by 9 commits, and can be fast-forwarded.
(use "git pull" to update your local branch)
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: pomodoro.html
no changes added to commit (use "git add" and/or "git commit -a")
[C:\Work\BitBucket\proj1] 14:32:53>git checkout pomodoro.html
[C:\Work\BitBucket\proj1] 14:33:00>git status
On branch work2
Your branch is behind 'origin/work2' by 9 commits, and can be fast-forwarded.
(use "git pull" to update your local branch)
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: pomodoro.html
no changes added to commit (use "git add" and/or "git commit -a")
[C:\Work\BitBucket\proj1] 14:33:04>
我使用git checkout -- pomodoro.html
命令得到了相同的结果。
因此,git 认为 pomodoro.html 文件已被修改,但当我使用该命令时却没有任何变化。
git difftool
我被告知这些文件是一样的。
不确定是否相关,但是在我的Git配置中,core.autocrlf
被设置为true
。 当我将其更改为false
时,我得到了相同的行为。
git commit -va
来查看差异。 - AD7six