1. 问题描述:
王修改了文件A并且push到了git server上,这时李也在修改文件A,但修改没有完成,李希望获得最新的代码,如果李直接pull的话会遇到一下问题:
error: Your local changes to the following files would be overwritten by merge:
***************************************
Please, commit your changes or stash them before you can merge.
造成冲突的原因:
2. 问题解决
2.1 commit your change
先提交你的改动,在更新代码
2.2 stash
git stash
git pull
git stash pop
git stash的作用是把本地的改动保存起来,、
然后在git pull 这样就不会有冲突的问题
最后git stash pop 就是把之前的改动merge到代码中。
2.3 merge
使用git merge --abort中止merge。merge manual中说,这条命令会尽力恢复到Merge之前的状态(可能失败!)。
merge manual中有一条警告:
Warning: Running git merge with uncommitted changes is discouraged: while possible, it leaves you in a state that is hard to back out of in the case of a conflict.
3. 参考文献
[1] http://www.cnblogs.com/sinojelly/archive/2011/08/07/2130172.html
[2] http://blog.csdn.net/iefreer/article/details/7679631
本文详细介绍了在使用Git进行版本控制时遇到冲突时的解决策略,包括如何提交更改、使用stash保存更改、手动合并代码等方法。同时,文章还提供了避免冲突的预防措施,确保团队成员能够顺利协作。
2837

被折叠的 条评论
为什么被折叠?



