LoginSignup
0
0

More than 1 year has passed since last update.

【Git】リモートブランチが削除されているのにローカルで見ると残っている時の削除方法【GitHub】

Posted at

はじめに

エラーを解消するためにリベースやら色々やった際に「revert-1-{ローカルブランチ名}」というブランチが生成されていて、 もう必要ないので削除しようとした所、削除されているのに表示されているというよくわからない状態になってしまったので、しっかり抹消できる方法を残しておきます。

とりあえず

「revert-1-{ローカルブランチ名}」このブランチを削除するために、 

git branch -d origin {ブランチ名}というコマンドを実行。(自分の環境では{ブランチ名}はrevert-1-feature/TopPage_Responsiveです)

$ git branch -d origin/revert-1-feature/TopPage_Responsive
error: branch 'origin/revert-1-feature/TopPage_Responsive' not found.

お??どうやらローカルブランチを削除する場合このコマンドでいけるが、リモートブランチを削除するコマンドはまた別にあるみたいなので調べました。

リモートブランチ削除コマンド

git push --delete origin <remote branch name>コマンドで行けそうなので実行。すると、、、

error: unable to delete 'origin/revert-1-feature/TopPage_Responsive': remote ref does not exist

ブランチを確認すると

$ git branch -a
* develop
  feature/ContactPage_AdminPage
  feature/TopPage_Responsive
  main
  remotes/origin/develop
  remotes/origin/feature/ContactPage_AdminPage
  remotes/origin/feature/TopPage_Responsive
  remotes/origin/main
  remotes/origin/revert-1-feature/TopPage_Responsive //こいつ消したい

どうやらまだ残っているみたいだ。

解決方法

git remote prune originこのコマンドで消せるみたい!実行してブランチを確認すると、、、

$ git branch -a
* develop
  feature/ContactPage_AdminPage
  feature/TopPage_Responsive
  main
  remotes/origin/develop
  remotes/origin/feature/ContactPage_AdminPage
  remotes/origin/feature/TopPage_Responsive
  remotes/origin/main

消えてますね!お疲れ様でした!

参考記事

0
0
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
0
0