2022年5月14日土曜日

gitのリポジトリからファイルを削除

% git clone [リポジトリ]
% git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch -r [対象ディレクトリ]' -- --all
% git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d

ディレクトリを削除したいので、「-r [対象ディレクトリ]」で実行した。うまく言った様子。ただ、「git push --all --force origin」でリポジトリに反映させようとしたが、remote(origin)がnon-bareリポジトリだったので、うまくいかず。「.git」ディレクトリ事置き換えてしまいました。(non-bareは関係ないかもしれないけど。。。。。)

(参考)
  • https://hatsune.hatenablog.jp/entry/2013/04/20/112606
  • https://qiita.com/Spring_MT/items/f60c391b5dbf569a1d12
  • https://zenn.dev/flyingbarbarian/articles/aaf59c07b71a34
あと、このコマンドも便利であった
git log --all --name-status --pretty=short --graph

0 件のコメント: