2012-08-01 24 views
0

我試圖在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.htmlgit rm public/index.html也沒有爲我做任何事情。然後我搜索了這個問題,並提出了一個StackOverflow文章,其中有人建議嘗試刷新git stashgit stash apply。我做到了,但仍然無法正常工作。

有什麼問題,我該如何解決?

+0

你需要「添加」刪除的文件,然後提交。 – Thilo 2012-08-01 00:32:29

回答

3

我認爲你必須提交基本的刪除,所以做了git的承諾-a -m「[評論]」,然後它會接受你刪除

0

關於git的過濾分支,它會刪除如果這是你想要的,那麼來自回購中所有提交的文件。在做之前只需進行提交或存儲更改。如果你只是希望它從現在開始刪除比seansmash的答案可能是你需要的。

相關問題