に参照されるようにfilter-branch
ような時間がかかり、破壊的なコマンドを実行する前に、問題の程度を評価する方法を探していますので、それは私がグーグルに欠けていたキーワードが判明「空」だった(など「なしファイルの変更をコミットを削除」を探していた)
一覧は何変化(空コミット)がないことをコミット:
git rev-list HEAD | while read commitHash; do
if [ $(git diff-tree --name-status --no-commit-id $commitHash | wc -l) -eq 0 ]; then
echo $commitHash
fi;
done
0123を
git rev-list HEAD | while read commitHash; do
git diff-tree --name-status $commitHash
done
カウント空コミット
git rev-list HEAD | while read commitHash; do
if [ $(git diff-tree --name-status --no-commit-id $commitHash | wc -l) -eq 0 ]; then
echo '1'
fi;
done | wc -l
カウント非空が
をコミット:
リストがの変更、および変更されたファイル(非空のコミットを)持っていることをコミット特に--commit-filter
git filter-branch --tag-name-filter cat --commit-filter 'git_commit_non_empty_tree "[email protected]"' -- --all
ドキュメントfilter-branch
に、::10
そして最後に、@JKillianさんの提案どおり、git filter-branch
を使用してレポからのすべての空のコミットを削除
https://git-scm.com/docs/git-filter-branch#git-filter-branch---commit-filterltcommandgt
おそらくHTTPS:/ /stackoverflow.com/a/28313729/3124288あなたが探しているのは何ですか? – JKillian
素晴らしいですが、これは容器を剪定するのに最適です。 –
@Whymarhここには小さな違いがあると思います。私は答えを見てみると、filter-branchのような破壊的なコマンドを使用する前に問題の程度を見ることに特に関心がありました。 –