9
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

リモートリポジトリのブランチを削除した後にローカルで表示される追跡ブランチを削除する

Posted at

リモートリポジトリのブランチを削除するには、空のブランチをpushすれば消える

しかし、リモートのブランチを削除しても、それを追跡していたブランチはローカルに残る場合がある。
そのブランチは下記コマンドで削除可能

git branch -d -r origin/coolbranch

リモートブランチを削除した直後の状態

console1
merge2% git branch -a                                                                                                                                                        [~/work/server/coolservice 17:56]
* develop
  issue_16985
  master
  remotes/origin/HEAD -> origin/master
  remotes/origin/develop
  remotes/origin/issue_16985
  remotes/origin/master

この状態からローカルに残ったリモート追跡ブランチissue_16985を削除

console2
merge2% git branch -d issue_16985                                                                                                                                            [~/work/server/coolservice 17:57]
Deleted branch issue_16985 (was 33650fb).
merge2% git branch -a                                                                                                                                                        [~/work/server/coolservice 17:57]
* develop
  master
  remotes/origin/HEAD -> origin/master
  remotes/origin/develop
  remotes/origin/issue_16985
  remotes/origin/master

削除された。

console3
merge2% git branch -d -r origin/issue_16985                                                                                                                                  [~/work/server/coolservice 17:57]
Deleted remote branch origin/issue_16985 (was 33650fb).
merge2% git branch -a                                                                                                                                                        [~/work/server/coolservice 17:57]
* develop
  master
  remotes/origin/HEAD -> origin/master
  remotes/origin/develop
  remotes/origin/master
merge2%   

参考
http://stackoverflow.com/questions/5094293/git-remote-branch-deleted-but-still-appears-in-branch-a

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?