Git--手动解决冲突-rebase使用

13,609 阅读1分钟

同事间使用git进行代码之间的协作。两个人同时修改了同一文件的相同内容。使用git pull 拉取代码之后会提示有冲突,并且git自动给你新建了一个分支no branch,rebasing master 。

解决冲突的步骤

  1. 手动解决相关冲突之后,使用git add ./ 随后使用git commit -m 提交之后;新建分支dev2

  2. 因为之前git自动给创建了一个no branch, rebasing master ,新建分支dev2,也和master分支在一个commit里面。所以切换到master分支,然后使用git merge dev2 两者合并一下;

  3. 使用git merge dev2 之后,自己还需要手动解决一下冲突,之后git add 和git commit -m 正常操作即可,最后git push,成功。这里不明白为什么将原来的no branch,rebasing master 变成av的一个分支,后续查一下。。。

  4. 最后检验一下是否有效果,使用git pull 拉取一下代码,提示如下:

5. 看提示,成功了。但是出现了fatal...信息
fatal: It seems that there is already a rebase-apply directory, and I wonder if you are in the middle of another rebase. If that is the case, please try git rebase (--continue | --abort | --skip) If that is not the case, please rm -fr ".git/rebase-apply" and run me again. I am stopping in case you still have something valuable there.
大概的意思就是说你可能两个rebase中间,如果不在中间,可以删除一下使用 rm -rf .git/rebase-apply 变基申请的文件。也可以手动删除一下,注意.git 是隐藏文件夹,设置一下显示就行
6. 再次使用git pull,成功,没有提示了