これに基づいて、私はgitリポジトリ全体、すべてのブランチ、タグ、およびコミット内のすべてのファイルの出現を取り除くための小さなスクリプトを作成しました。 スクリプト:すべてのgitの履歴からファイルを削除する
#!/usr/bin/env node
var child_process = require('child_process');
if (process.argv.length < 3){
console.error('USAGE: git-forget path/to/file')
process.exit(1);
}
var path = process.argv[2];
var phase = 0;
function printLog(error, stdout, stderr) {
if (error) {
console.error('ERROR' + error);
}
console.log(++phase);
console.log(stdout);
}
child_process.execSync('git filter-branch --force --index-filter \'git rm -f --cached --ignore-unmatch '+ path +'\' --prune-empty --tag-name-filter cat -- --all');
child_process.execSync('echo "' + path + '" >> .gitignore', printLog);
child_process.execSync('git add .gitignore');
child_process.execSync('git commit -m "Add ' + path +' to .gitignore"',printLog)
child_process.execSync('git push origin --force --all',printLog);
child_process.execSync('git push origin --force --tags',printLog);
このスクリプトは、(プライベートで)いくつかのリポジトリに、それは最初の私が削除しようとしていたファイルにコミットまま特定のものに取り組みました。スクリプトが実行された後、私はこれを行いgit log --all -- .npmrc
と最初のコミットが見つかりました。私は何が欠けていますか?
sidenote:checkout [BFG、git-filter-branchのより簡単で高速な代替方法](http://rtyley.github.io/bfg-repo-cleaner) – laggingreflex
はbfgを試しましたが、ローカルでは動作しますが更新はしませんリモート – qballer
@ qballer、強制的にあなたの変更をリモートにプッシュしますか? – Chris