1
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 5 years have passed since last update.

gitでsquashする(rebase)

1
Last updated at Posted at 2019-07-21

備忘録です

やりたいこと

ブランチ切って開発が完了。
適度にローカルリポジトリにcommitしたはいいが、
リモートリポジトリにpushする前にはある程度まとめておきたい

やりかた

git rebase を使う

以下は直近3コミットをまとめる場合

git rebase -i HEAD~3

どれをrebaseするのか聞かれるので、
pick → squashに変更する

pick 111111 コミットコメント3
squash aaaaaa コミットコメント2
squash bbbbbb コミットコメント1

最後にrebaseしたcommitのコメント入力なので、
適切なものを入れる
(予めこれまでのコメントが入るので、適当にマージする)

# This is a combination of 2 commits.
# The first commit's message is:

コミットコメント3

# This is the commit message #2:

コミットコメント2

# This is the commit message #1:

コミットコメント1

# Please enter the commit message for your changes. Lines starting
...

ドキュメント

Git - git-rebase Documentation

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