2014-04-03 124 views
1

我犯了一個大文件的刪除。現在我想從我的本地.git中取出這個大文件。任何可以遵循的步驟都可行?如何從提交歷史中完全刪除文件?

我想:

git filter-branch --index-filter "git rm -rf --cached --ignore-unmatch$files" HEAD 

git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch $file' --prune-empty --tag-name-filter cat -- --all 
+0

命令'GIT中濾波器分支--force --index濾波器 'git的RM --cached - 忽略UNMATCH $ Rake文件' --prune-空--tag-name-filter cat - --all'適用於我。處於repo-root目錄和$ Rakefile中,包括要刪除的文件的相對路徑。 'linux,git version 2.6.4'。 – dr0i

回答

0

您正在尋找神奇的git的命令是git filter-branch,它可以讓您編輯混帳回購協議。在實施例第一個例子是:

Suppose you want to remove a file (containing confidential information 
    or copyright violation) from all commits: 

     git filter-branch --tree-filter 'rm filename' HEAD 
+0

無法創建新的備份。 以前的備份已經存在於refs/original/ 強制覆蓋備份-f – Paul

+0

添加'-f'作爲該參數強制執行的東西,所以:'git filter-branch -f --tree-filter' rm文件名'HEAD' – dr0i