0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

#9 Git ローカルブランチを削除して、ローカルから取得しなおす

Last updated at Posted at 2025-04-13

はじめに

ローカルブランチを削除して、取り直したいということがありましたのでコマンドについて調べました。コマンドをメモしておきます。

ローカルブランチの削除

まずはローカルブランチの削除をします。削除したいローカルブランチ以外をチェックアウトしておいてください。

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

上記どちらのコマンドでOKです。ただい、このコマンドではマージ済みのブランチに限られます。
マージされていないブランチを削除したい場合は以下のコマンドで削除します。

$ git branch -D ブランチ名

ローカルブランチの再作成

以下のコマンドでブランチを再作成します。

$ git checkout -b ブランチ名 origin/チェックアウトするブランチ名

以上です。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?