我試圖在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