2

git filter-branchファイル/ディレクトリを履歴から完全に削除する正規表現を渡す方法はありますか?

4

1 に答える 1

3

インデックス フィルターを実行する場合 (ワーク ツリーを変更する必要はありません)、すべてのコミットに対してスクリプトを作成し、必要なファイルのみを sed、egrep、または grep の出力で変更できますgit ls-files

git ls-files --cached | \
sed 's/weirdprefix\(pattern\)/git reset HEAD weirdprefix\1/g' | \ 
xargs -i{} sh -c '{}'

(これは、filter-branch コマンドで提供するスクリプトです)

ドキュメントの例を次に示します ( http://www.kernel.org/pub/software/scm/git/docs/git-filter-branch.html ):

git filter-branch --index-filter \
        'git ls-files -s | sed "s-\t\"*-&newsubdir/-" |
                GIT_INDEX_FILE=$GIT_INDEX_FILE.new \
                        git update-index --index-info &&
         mv "$GIT_INDEX_FILE.new" "$GIT_INDEX_FILE"' HEAD
于 2012-09-26T18:57:37.757 に答える