2011-03-25 85 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}"