git冲突了怎么办,如何高效快速的解决代码冲突?

相信不少同窗在项目开发阶段,都会遇到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 pullget

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

相关文章
相关标签/搜索