1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

github リモートにもう存在しない削除されたブランチをローカルから削除する方法

Posted at

コード

git fetch --prune
git branch -vv | grep ': gone]' | awk '{print $1}' | xargs -r git branch -d

コードの解説

  • git fetch --prune: リモート追跡ブランチを最新に。
  • git branch -vv: ローカルブランチと追跡状態を確認。
  • grep ': gone]': 消えた(リモートにない)ものだけ抽出。
  • awk '{print $1}': ブランチ名だけ取り出す。
  • xargs git branch -d: それらのブランチを削除。
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?