# Squash Merge v.s. Merge ###### tags: `git` ## 優點 在 github 上使用,每個 commit 可以直接看到屬於哪個 PR。 ## 缺點 - 如果刪掉開發的 branch,離開 github 後,就難以 trace 每個 branch 內的開發過程。 > 不要離開 github 就好,讚讚讚 - 需要 rebase,如果沒有正確 rebase 容易 conflict。 > 正確使用應該就不算缺點? ### Conflict 狀況 有 a, b, c 三個在開發中的 branch:  假設: - a 先完成,merge 進 master。 - c 完成, merge 進 master。 - b 想要在有 `c.txt` 的狀況下繼續開發,所以要 merge master。 #### 用 merge merge 完 a, c 後 checkout 到 b 的狀態:  這時 `git merge master` 就很順利,不會有任何 conflict,直接 merge 完成:  #### 用 squash merge merge 完 a, c 後 checkout 到 b 的狀態:  這時 `git merge master` 就會產生 conflict:  ##### 解法 merge 完 a, c 後,b 先 rebase master 上 squash merge a 的 commit  再 merge master 
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up