Squash Merge v.s. Merge
優點
在 github 上使用,每個 commit 可以直接看到屬於哪個 PR。
缺點
Conflict 狀況
有 a, b, c 三個在開發中的 branch:
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
假設:
- a 先完成,merge 進 master。
- c 完成, merge 進 master。
- b 想要在有
c.txt
的狀況下繼續開發,所以要 merge master。
用 merge
merge 完 a, c 後 checkout 到 b 的狀態:
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
這時 git merge master
就很順利,不會有任何 conflict,直接 merge 完成:
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
用 squash merge
merge 完 a, c 後 checkout 到 b 的狀態:
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
這時 git merge master
就會產生 conflict:
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
解法
merge 完 a, c 後,b 先 rebase master 上 squash merge a 的 commit
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
再 merge master
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →