git reabse 出現 error: cannot 'squash' without a previous commit first commit
```
* ccccccc - (HEAD -> feature/test) C (1 second ago)
* bbbbbb - (origin/feature/test) B
* aaaaaaa - (origin/main, origin/HEAD) A
```
在 feature/test 對於 想 git rebase -i aaaaaaa 去 squash B C 兩個 commit
git rebase -i aaaaaaa
會出現
pick bbbbbb B
pick ccccccc C
# Rebase aaaaaaa.. ccccccc onto aaaaaaa (2 commands)
#
# Commands:
# p, pick <commit> = use commit
# r, reword <commit> = use commit, but edit the commit message
# e, edit <commit> = use commit, but stop for amending
# s, squash <commit> = use commit, but meld into previous commit
# f, fixup [-C | -c] <commit> = like "squash" but keep only the previous
# commit's log message, unless -C is used, in which case
# keep only this commit's message; -c is same as -C but
# opens the editor
如果在改成
s bbbbbb B
s ccccccc C
會出現 error: cannot 'squash' without a previous commit first commit
這時候可以使用 r, reword <commit> = use commit, but edit the commit message 去 squash 包含第一個commit
r bbbbbb B
s ccccccc C
沒有留言:
張貼留言