git bash、eclipse中git插件提交出现冲突以及解决办法
git bash提交到本地仓库后,执行git push origin时报错
error: failed to push some refs to 'https://github.com/XiangNo1/gtitest.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
解决办法:
1.执行命令将远程代码拉到本地:git pull origin,会提示有冲突需要解决的文件
Auto-merging test.txt
CONFLICT (content): Merge conflict in test.txt
Automatic merge failed; fix conflicts and then commit the result.
2.打开这个test.txt测试文件,如下显示:
this is test
test111111
test222222222
test333333333333
<<<<<<< HEAD
test9999999
=======
test88888888888888
>>>>>>> db5f7ccd0d4fc1822f13c60cb349e8e89dde4ea7
3.此时只需要将文件修改,将冲突部分去掉然后改成自己想要的,再执行git add和gitcommit 然后git push即可解决冲突。
git bash,直接执行git pull origin时报错
error: Your local changes to the following files would be overwritten by merge:
test.txt
Please commit your changes or stash them before you merge.
Aborting
Updating db5f7cc..937df47
解决办法:
1.将本地文件提交到本地仓库(git add、git commit两步)
2.执行git pull origin
$ git pull origin
Auto-merging test.txt
CONFLICT (content): Merge conflict in test.txt
Automatic merge failed; fix conflicts and then commit the result.
3.打开这个test.txt测试文件,如下显示:
this is test
test111111
test222222222
test333333333333
<<<<<<< HEAD
test88888888888888
test100101010101
=======
test9999999
test88888888888888
>>>>>>> 937df476924fa50133d370f652d52178e53a0213
4.此时只需要将文件修改,将冲突部分去掉然后改成自己想要的,再执行git add和gitcommit 然后git push即可解决冲突。
eclipse的git插件解决冲突
(eclipse 用git插件首先将这个对勾去掉:设置-team-git-committing-use staging view….)
eclipse的git插件解决冲突方法:
1.pull,如果pull出错说明有冲突文件。
2.同步一下工作状态,查看一下哪些文件有冲突。
3.commit到本地仓库。
4.pull。文件显示冲突区域。
5.解决冲突,并且add to index。
6.commit到本地仓库。
7.push到远程仓库。
(注意:期间会commit两次,这两次的日志都会显示出来。)
还没有评论,来说两句吧...