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】分割してコミットする方法

Posted at

gs branch split を使用すると1つのブランチを特定のコミット位置で複数のブランチに分割できます。
大きな機能を論理的な単位で複数のPRに分けたい場合に便利です。

基本的な使い方

# 対話的に分割
gs branch split

# 特定のコミットで分割
gs branch split --at HEAD^:new-branch-name

# 複数箇所で分割
gs branch split --at HEAD~2:part1 --at HEAD^:part2

主要オプション

--at COMMIT:NAME

分割位置を指定します。

# 特定のコミットハッシュで分割
gs branch split --at 1234567:feature-a

# HEADから2つ前のコミットで分割
gs branch split --at HEAD~2:refactor-part

--branch NAME

現在のブランチ以外を分割対象にします。

gs branch split --branch feature-branch --at HEAD^:split-branch

実例

分割前

feature-branch
├── commit3: Add tests
├── commit2: Implement feature
├── commit1: Setup
└── main

分割実行

gs branch split --at HEAD^:implement-feature

分割後

feature-branch (commit3のみ)
├── implement-feature (commit2まで)
├── commit1: Setup  
└── 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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?