Azureの小ネタ (改)

~Azureネタを中心に、色々とその他の技術的なことなどを~

ローカルに残ったままのリモートブランチの残骸を削除する

よくこういう状態におちいって、グルグル地獄になるので、備忘録代わりのエントリ。

Git - 削除されたremoteブランチがローカルのRepoに残っていて、それを削除する方法 - Qiita

git remote show origin
git remote prune --dry-run origin
git remote prune origin

以下、リポジトリの確認、空実行、実行の例です。

$ git remote show origin
* remote origin
  Fetch URL: https://hoge@bitbucket.org/foo/bar.git
  Push  URL: https://hoge@bitbucket.org/foo/bar.git
  HEAD branch: master
  Remote branches:
    master                      tracked
    refs/remotes/origin/Fix28 stale (use 'git remote prune' to remove)
    refs/remotes/origin/Fix33 stale (use 'git remote prune' to remove)
  Local branch configured for 'git pull':
    master merges with remote master
  Local ref configured for 'git push':
    master pushes to master (up to date)

hoge@ZOO /c/ws/bar (master)
$ git remote prune --dry-run origin
Pruning origin
URL: https://hoge@bitbucket.org/foo/bar.git
 * [would prune] origin/Fix28
 * [would prune] origin/Fix33

hoge@ZOO /c/ws/bar (master)
$ git remote prune  origin
Pruning origin
URL: https://hoge@bitbucket.org/foo/bar.git
 * [pruned] origin/Fix28
 * [pruned] origin/Fix33