2
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?

More than 1 year has passed since last update.

GitでPRから特定のコミットを排除する

2
Last updated at Posted at 2024-03-31

初めに

PRを作るときに前回のタスクのコミットを引き継いでたりとか、rebaseの時に間違ったりとかして不要なコミットが紛れ込んでしまうことがあります。
今回はそれを解決する方法です。

GitでPRから特定のコミットを排除する方法

1. rebase

ローカルブランチ実行
10の部分は削除したいコミットの1つ前までの数字(HEAD~10の部分はコミット番号でもいける)

$ git rebase -i HEAD~10

2. 削除

エディタが開くと思うので削除したいコミットのpickdropに変更
:wqで保存してエディタを抜ける

3. push

最後にpushする

$ git push -f origin {ブランチ名}
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?