2011-03-25 68 views
1

我使用Grit/Git作爲數據庫來跟蹤添加到博客的文件。Grit在提交中刪除文件

我找不到如何從索引中刪除文件的任何示例。我仍然希望能夠在我的Git歷史記錄中擁有該文件(能夠通過恢復提交歷史記錄來獲取該文件),但是我想從當前的HEAD中刪除它。

任何提示或技巧?

回答

0

這應該工作:

require 'grit' 

    repo_path = '/Users/alagu/code/myproject/' 
    removable_file = '/Users/alagu/code/myproject/file.txt' 
    repo = Grit::Repo.new(repo_path) 
    Dir.chdir(repo_path) 
    repo.remove([removable_file]) 
    repo.commit_index "Deleted #{removable_file}"