git bash、eclipse中git插件提交出现冲突以及解决办法
生活随笔
收集整理的這篇文章主要介紹了
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 >>>>>>> db5f7ccd0d4fc1822f13c60cb349e8e89dde4ea73.此時只需要將文件修改,將沖突部分去掉然后改成自己想要的,再執行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 >>>>>>> 937df476924fa50133d370f652d52178e53a02134.此時只需要將文件修改,將沖突部分去掉然后改成自己想要的,再執行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兩次,這兩次的日志都會顯示出來。)
總結
以上是生活随笔為你收集整理的git bash、eclipse中git插件提交出现冲突以及解决办法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux根据条件查找文件、根据文件内容
- 下一篇: VUE—从入门到飞起(一)