相信不少同窗在項目開發階段,都會遇到Git衝突,項目參與人數越多發生的機率越大。git
對於接觸git不久的同窗可能會盲目的百度:spa
Save your local code, return your local code version, and so on.code
git reset --hard commitID
事件
Someone will force the submission of code, maybe someone will force the get of code.開發
git push -u origin master -f
OR git reset --hard git pull
get
Anyway,我認爲在團隊合做期間代碼發生衝突事件須要人工解決衝突代碼,這一點應該是沒法改變的。同步
如何快捷方便管理你的本地代碼,在不被覆蓋的狀況下同步線上最新的代碼與在本地合併後解決衝突再提交 ?it
1、git stash [massage] massage可選,爲保存本地代碼備註。io
2、git pull 保存本地代碼後進行pullast
3、git stash list 查看stash保存列表
4、git stash pop 獲取最新一次stash保存內容,恢復現場代碼及修改。
5、手工解決衝突代碼。
6、git add. git commit -m {} git push
記得git stash drop stash id(list查看)或者 git stash clear刪除全部存儲。
以上是我的在遇到衝突後認爲比較快速解決並不會覆蓋本地代碼的方式。
能夠的話仍是但願遵照Gitflow開發流程 ^ _ ^
若是有同窗有更好的解決方法,歡迎留言。
study hard and make progress every day