简体   繁体   English

Git 合并冲突问题,拉动时gir合并冲突

[英]Git merge conflict issue, gir merge conflict while pulling

My coworker and I are working in the same branch which was cut from develop.我和我的同事在从开发中删除的同一个分支中工作。 There are many files to be taken care of by both of us.有很多文件需要我们两个人处理。 The scenario I'm facing is that I did some changes and pushed my code to the remote repo.我面临的情况是我做了一些更改并将我的代码推送到远程仓库。 My coworker also did some changes in his local and and now he is not able to take a pull.我的同事也在他的本地做了一些改变,现在他无法接受。 It shows merge conflict while pulling.它在拉动时显示合并冲突。

Can someone let me know how can we resolve this?有人可以让我知道我们该如何解决这个问题吗? Based on my understanding, I think we made some changes in the same files and now to merge them, git is causing that conflict.根据我的理解,我认为我们对相同的文件进行了一些更改,现在合并它们,git 导致了冲突。

First, make sure to use:首先,确保使用:

git config --global pull.rebase true
git config --global rebase.autoStash true

That way, a simple git pull will:这样,一个简单的 git 拉动将:

  • stash your work in progress隐藏你正在进行的工作
  • rebase your local commits (not yet pushed) on top of the updated remote upstream branch (instead of merging).在更新的远程上游分支(而不是合并)之上重新设置本地提交(尚未推送)。 That keep the history linear.保持历史线性。

You can also activate rerere in order to not resolve the same conflict over and over again.您还可以激活rerere ,以免一遍又一遍地解决相同的冲突。

Finally, in case of merge/rebase conflict, you will need to chose between "our" and "their" version in each file with conflict markers.最后,在合并/变基冲突的情况下,您需要在每个带有冲突标记的文件中选择“我们的”和“他们的”版本。 As shown here , an IDE can help facilitate the visualization and resolution of such conflicts.如此处所示,IDE 可以帮助促进此类冲突的可视化和解决。

I used tortoise git我用的是乌龟git

git tortoise > git diff git 乌龟 > git 差异

Then I manually resolved the git merge conflict by removing or modifying the code I didn't want.然后我通过删除或修改我不想要的代码手动解决了 git 合并冲突。 Then I committed the code and the issues were gone.然后我提交了代码,问题就消失了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM