王修改了文件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.
造成冲突的原因:
先提交你的改动,在更新代码
git stash
git pull
git stash pop
git stash的作用是把本地的改动保存起来,、
然后在git pull 这样就不会有冲突的问题
最后git stash pop 就是把之前的改动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.
[1] http://www.cnblogs.com/sinojelly/archive/2011/08/07/2130172.html
[2] http://blog.csdn.net/iefreer/article/details/7679631
原文:http://blog.csdn.net/matrix_laboratory/article/details/18034509