🔶

[Git] 削除済リモートブランチが表示される時の対処法

2023/05/23に公開
問題

削除済みのリモートブランチが表示されている状態では、

$ git branch -a
...
remotes/origin/<branch>
...

そのブランチを削除しようとしても(既に存在しないため)消せない.

$ git push origin :<branch>
error: unable to delete <branch>: remote ref does not exist
error: failed to push some refs to 'YYYYY'
対処法

リモート名に関連づけられている古い参照を削除する.

$ git remote prune origin
$ git branch -a
# 表示が消えていることを確認

https://git-scm.com/docs/git-remote#Documentation/git-remote.txt-empruneem

Discussion