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?

【git-spice】ブランチ名を変更する方法

Last updated at Posted at 2025-08-09

変更方法

git-spiceでブランチ名を変更するには、gs branch renameコマンドを使用します。

指定したブランチの名前を変更

既存のブランチ名を新しい名前に変更するには以下のようにします。

gs branch rename <old-name> <new-name>

例:

gs branch rename feature-old feature-new

現在のブランチ名を変更

現在チェックアウトしているブランチの名前を変更には以下のようにします。

gs branch rename <new-name>

例:

gs branch rename feature-improved

インタラクティブに変更

プロンプトを使って対話的にブランチ名を変更には以下のようにします。

gs branch rename

git-spiceが現在のブランチ名の変更をインタラクティブに案内してくれます。

コマンドエイリアス

gs branch renameは以下の短縮形でも実行できます。

  • gs branch rn
  • gs branch mv
# これらは全て同じ動作をします
gs branch rename feature-old feature-new
gs branch rn feature-old feature-new
gs branch mv feature-old feature-new

git branch -m を使った場合の対処

通常のGitコマンド(git branch -m)でブランチ名を変更した場合、git-spiceはその変更を自動的に認識しません。この場合は、以下のコマンドを使用してブランチのトラッキング状態を手動で更新する必要があります。

# 古いブランチ名のトラッキングを解除
gs branch untrack <old-branch-name>

# 新しいブランチ名でトラッキングを開始
gs branch track <new-branch-name>

参考

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?