我试图在Heroku上放置一个新的Rails应用程序,并删除了默认索引文件public/index.html。然而,令我惊讶的是,当我访问Heroku上的应用程序时,我显示了默认的索引页面,而不是我想要查看的索引。Git不会删除一个文件,并总是认为工作目录很脏
好吧,这有点奇怪,但我想可能有一些原因,比如Git没有从存储库中删除文件,即使我删除了它。于是我抬起头在互联网上如何给力的Git从库中删除文件,并用
git filter-branch --tree-filter 'rm public/index.html' HEAD
来到了,当我跑了这一点,但是,它说:“不能改写分支(ES)用肮脏的工作目录”。我不确定为什么我的工作目录是肮脏的,因为我刚刚提交,当我跑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
这是令人困惑的我,因为我的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
。我做到了,但仍然无法正常工作。
有什么问题,我该如何解决?
你需要“添加”删除的文件,然后提交。 – Thilo 2012-08-01 00:32:29