git bash、eclipse中git插件提交出现冲突以及解决办法

我就是我 2023-02-19 04:26 124阅读 0赞

git bash提交到本地仓库后,执行git push origin时报错

  1. error: failed to push some refs to 'https://github.com/XiangNo1/gtitest.git'
  2. hint: Updates were rejected because the remote contains work that you do
  3. hint: not have locally. This is usually caused by another repository pushing
  4. hint: to the same ref. You may want to first integrate the remote changes
  5. hint: (e.g., 'git pull ...') before pushing again.
  6. hint: See the 'Note about fast-forwards' in 'git push --help' for details.

解决办法:

1.执行命令将远程代码拉到本地:git pull origin,会提示有冲突需要解决的文件

  1. Auto-merging test.txt
  2. CONFLICT (content): Merge conflict in test.txt
  3. Automatic merge failed; fix conflicts and then commit the result.

2.打开这个test.txt测试文件,如下显示:

  1. this is test
  2. test111111
  3. test222222222
  4. test333333333333
  5. <<<<<<< HEAD
  6. test9999999
  7. =======
  8. test88888888888888
  9. >>>>>>> db5f7ccd0d4fc1822f13c60cb349e8e89dde4ea7

3.此时只需要将文件修改,将冲突部分去掉然后改成自己想要的,再执行git add和gitcommit 然后git push即可解决冲突。

git bash,直接执行git pull origin时报错

  1. error: Your local changes to the following files would be overwritten by merge:
  2. test.txt
  3. Please commit your changes or stash them before you merge.
  4. Aborting
  5. Updating db5f7cc..937df47

解决办法:

1.将本地文件提交到本地仓库(git add、git commit两步)

2.执行git pull origin

  1. $ git pull origin
  2. Auto-merging test.txt
  3. CONFLICT (content): Merge conflict in test.txt
  4. Automatic merge failed; fix conflicts and then commit the result.

3.打开这个test.txt测试文件,如下显示:

  1. this is test
  2. test111111
  3. test222222222
  4. test333333333333
  5. <<<<<<< HEAD
  6. test88888888888888
  7. test100101010101
  8. =======
  9. test9999999
  10. test88888888888888
  11. >>>>>>> 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两次,这两次的日志都会显示出来。)

发表评论

表情:
评论列表 (有 0 条评论,124人围观)

还没有评论,来说两句吧...

相关阅读

    相关 Git提交解决冲突

    一、git命令在提交代码前,没有pull拉最新的代码,因此再次提交出现了冲突 ![在这里插入图片描述][474b05332bc548fe94a2da281e11d5aa.

    相关 git 冲突解决办法

    在项目中使用git管理,冲突是在所难免的,如果没办法解决冲突,可以试试这个办法! 第一步、对工程进行备份,最好是拷贝到其他文件夹中 第二步、在cmd命令栏上,进入到工程目录

    相关 git 解决冲突办法

    在项目中使用git管理,冲突是在所难免的,如果没办法解决冲突,可以试试这个办法! 第一步、对工程进行备份,最好是拷贝到其他文件夹中 第二步、在cmd命令栏上,进入到工程目录

    相关 eclispe git冲突解决办法

    git冲突解决办法   当工程目录出现向下 箭头,向上箭头时候,说明 1 向下箭头 说明要先拉下代码 ,当前本地代码落后于服务器版本 2 先选择和服务器不同的文件,