重置困难的问题

时间:2014-02-27 16:45:54

标签: git

我已经在我的存储库工作了一段时间但最近在我的一个文件上收到了一个奇怪的状态,我将其命名为file.py(我还将当前分支命名为my_branch)。我不确定是什么让GIT处于这种状态,但我似乎可以修复它(不会回到克隆整个项目)。 GIT现在似乎与我的变化完全混淆,并且拒绝恢复旧的变化。

$ rm file.py
$ git reset --hard
HEAD is now at 42d1b0b Documentation for various modules.
$ ls | grep file.py
file.py
$ git status
On branch my_branch
Your branch is up-to-date with 'origin/my_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:   File.py

no changes added to commit (use "git add" and/or "git commit -a")

这里有一点注意,作为git状态的一部分列出的File.py由于某种原因确实是大写的。文件file.py被拉低为小写。此时,我很沮丧,想要重新开始工作,所以我试着清理一切。

$ git clean -dxf
// Various files cleaned
$ rm file.py
$ git pull
Already up-to-date.
$ git reset --hard
HEAD is now at 42d1b0b Documentation for various modules.
$ ls | grep file.py
file.py
$ git status
On branch my_branch
Your branch is up-to-date with 'origin/my_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:   File.py

no changes added to commit (use "git add" and/or "git commit -a")

又来了!运行git diff file.py也会产生差异。但差异与我上一次提交的差异相同。尝试添加文件也无济于事,因为它默默地忽略了我的请求。

有什么建议吗?

1 个答案:

答案 0 :(得分:0)

备份文件并使用git rm file.py将其删除。

然后将ignore选项添加到你的git repo:

git config core.ignorecase true