我创建了一个新的存储库,并添加了一个Readme.md文件。现在,这已添加到远程存储库中。然后我将远程克隆到我的本地机器并添加了一些.ignore文件并在主分支中暂存该文件。后来我决定在提交其他文件时只想将README恢复到原始状态,所以我首先暂存并只提交.ignore文件,然后我尝试了以下命令来撤消对自述文件的更改:
git reset HEAD README.md
git checkout -- README.md
当那些不起作用时我尝试了
git checkout HEAD -- README.md
git reset --hard <commit id> README.md
git reset --hard HEAD README.md
git reflog README.md
git checkout <commit id> README.md
git checkout README.md
这些似乎都没有奏效。当我点击命令git status
时,我看到以下输出: -
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)
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: README.md
no changes added to commit (use "git add" and/or "git commit -a")
有人可以帮忙吗?如何让README文件显示为未修改并将其恢复为远程服务器上的状态?