GitHub“不能自动合并"? [英] GitHub "can't automatically merge"?

查看:75
本文介绍了GitHub“不能自动合并"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时当我尝试将头叉合并到我的基础叉中,或将我的基础叉合并到头叉中时,我会在 GitHub 上收到以下消息:

Sometimes when i try to merge the head fork into my base fork, or my base fork into the head fork, I get the following message on GitHub:

无法自动合并.别担心,您仍然可以创建拉取请求."

"Can’t automatically merge. Don’t worry, you can still create the pull request."

如果有冲突,我该如何查看?

How do I view the conflicts, if there are any for this?

我已经阅读了大约 10 个带有各种命令的不同示例,但我无法说出示例中的名称在我的情况下适用于哪些情况,因为存在不同的基础、分叉、分支等名称.

I have read about 10 different examples with various commands but I can't tell what the names in the examples apply to in my situation as different names for bases, forks, branches, etc, exist.

在这一切之后,我无法相信没有您可以键入的命令来查看冲突、编辑冲突并继续合并.如果有,我还没有找到.

After all of this, I can't believe there isn't a command you can type to see the conflicts, edit the conflicts and go on with merging. If there is, I haven't found it yet.

推荐答案

假设有 your-branch 和 master 分支.您想将您的分支中的更改合并到 master 中以供其他人查看,但同时其他人对 master 进行了相互冲突的更改(例如合并他们的 PR).在创建 PR 之前将 master 合并到你的分支中(即以相反的方式进行合并)通常很有用.

Let's say there is your-branch and the master branch. You want to merge changes from your-branch into the master for others to see them, but someone else did conflicting changes to the master (e.g. merging their PR) in the meantime. It is often useful to merge master into your-branch (i.e. do the merge the other way round) before creating the PR.

在命令行中,您可以:

git checkout master
git pull
git checkout your-branch
git merge master

现在您可以看到冲突列表.按照您从 git 获得的消息解决冲突.您可以使用自己喜欢的工具,这样就简单多了.最后,您提交并推送.当你重新创建 PR 时,应该没有冲突.

Now you can see the list of conflicts. Follow the messages you get from git to resolve the conflicts. You can use your favorite tools, so it is way easier. Finally, you commit&push. When you re-create the PR, there should be no conflicts.

这篇关于GitHub“不能自动合并"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆