LoginSignup
14
13

More than 3 years have passed since last update.

[git merge --squash]commitを1つにまとめてと言われたら。

Last updated at Posted at 2018-02-21

プルリクエストに対してコミットがたくさんになってしまい、
「commitを1にまとめて」と言われることがあると思います。

その時は下記をの通りに実行

登場するブランチ

  • 作業ブランチのマージ先
    • develop
  • 作業ブランチ
    • feature/example_999
  • 一時作成用ブランチ
    • tmp
$ git checkout feature/example_999 # 作業ブランチへ移動しておく
$ git branch -m feature/example_999 tmp # -m ブランチ名を変える
$ git checkout develop # 作業ブランチのマージ先ブランチに切り替える
$ git checkout -b feature/example_999 # 作業ブランチと同じ名前のブランチを作成
$ git merge --squash tmp # 1つにまとめる
$ git commit -m "squash" # commit
$ git push origin feature/example_999 -f # push
$ git branch -D tmp # tmpブランチを削除
14
13
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
14
13