我试图在 Heroku 上放置一个新的 Rails 应用程序,并删除了默认索引文件 public/index.html。然而,令我惊讶的是,当我在 Heroku 上访问我的应用程序时,我看到的是默认索引页面,而不是我想要查看的索引。
好的,这有点奇怪,但我想可能有一些原因,比如 Git 没有从存储库中删除文件,即使我删除了它。所以我在网上查了如何强制Git从存储库中删除文件并想出了
git filter-branch --tree-filter 'rm public/index.html' HEAD
但是,当我运行它时,它说“无法用脏工作目录重写分支”。我不确定为什么我的工作目录很脏,因为我刚刚提交,当我运行git status
它时说
# On branch master
# Changes not staged for commit:
# (use "git add/rm <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# deleted: public/index.html
这让我很困惑,因为我很久以前就删除了 public/index.html。为什么它应该是唯一剩下的变化?尽管如此,我还是跑了git add .
,git commit -m "..."
它说
# On branch master
# Changes not staged for commit:
# (use "git add/rm <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# deleted: public/index.html
#
no changes added to commit (use "git add" and/or "git commit -a")
然后,我很生气,尝试git add .
并git status
看到根本没有添加更改。 git add public/index.html
也git rm public/index.html
没有为我做任何事情。然后我用谷歌搜索了这个问题,并想出了一个 StackOverflow 帖子,有人建议尝试git stash
并git stash apply
刷新。我这样做了,但事情仍然没有奏效。
有什么问题,我该如何解决?