LoginSignup
2
0

More than 1 year has passed since last update.

ブランチの削除・ブランチの復元 Git

Posted at

用途

ブランチを削除・復元したいときに使う。

使用方法

ブランチを削除

$ git branch -d ブランチ名
$ git branch -d hoge

複数のブランチを削除

$ git branch -d ブランチ名1 ブランチ名2
$ git branch -d hoge hogehoge

オプション

$ git branch -d ブランチ名

-d はマージやプッシュをしていないブランチは削除できない。

$ git branch -D ブランチ名

-D は強制的に削除できる。

ブランチを復元(削除した際のハッシュ値を使用する。)

$ git branch -d hoge

上記で hogeブランチ を間違って削除してしまった時に以下の文が表示される。
〇〇〇〇がハッシュ値だからメモしておく。

Deleted branch hoge (was 〇〇〇〇).

復活させるには以下のコマンドを流す。(〇〇〇〇はハッシュ値)

$ git checkout 〇〇〇〇 -b hoge
2
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
2
0