- 追加された行はこの色です。
- 削除された行はこの色です。
* git rebaseで複数のコミットを1つにまとめる [#pf43b768]
*** 1. git logでコミットログを確認する [#u011dd97]
$ git log --oneline
71f4d70 commit#3
934d01c commit#2
7d19a73 commit#1
$ git rebase -i
このうち、#2と#3を1つにまとめる事にする。
> pick 934d01c commit#2
> pick 71f4d70 commit#3
↓
> pick 934d01c commit#2
> s 71f4d70 commit#3
*** 2. git rebaseを実行する [#y82beb29]
> # This is a combination of 2 commits.
> # The first commit's message is:
>
> commit#2
>
> # This is the 2nd commit message:
>
> commit#3
$ git rebase -i 7d19a73
↓
#1のコミットIDである7d19a73を指定する。すると、以下のようにメッセージが出るので、
> commit#2 and commit#3
pick 934d01c commit#2
pick 71f4d70 commit#3
$ git log --oneline
08984ad commit#2 and commit#3
7d19a73 commit#1
↓のように#3をs(squash)に指定する。
pick 934d01c commit#2
s 71f4d70 commit#3
*** 3. コミットのやり直し [#ja21b010]
2.の続きでコミットメッセージの記述を促されるので、
# This is a combination of 2 commits.
# The first commit's message is:
commit#2
# This is the 2nd commit message:
commit#3
↓ 今回は以下のようにした。
commit#2 and commit#3
*** 4. コミットログの確認 [#a34ff2c8]
これで以下のように#2と#3のコミットがまとめられた。
$ git log --oneline
08984ad commit#2 and commit#3
7d19a73 commit#1