如何解决如何在本地强制合并两个远程分支?
我正在尝试将我的本地分支从不同的存储库合并到我的上游代码。我想在我的开发系统中将 priv/dev
分支合并到 origin/master
。我想优先考虑我的更改而不是原始主机。然而它失败了,我的代码有错误吗?
git clone https://github.com/production public_code
cd public_code
git remote add priv https://gitlab.com/tmv/development
git merge -Xours priv/dev origin/master
输出
error: Merging is not possible because you have unmerged files.
hint: Fix them up in the work tree,and then use 'git add/rm <file>'
hint: as appropriate to mark resolution and make a commit.
fatal: Exiting because of an unresolved conflict.
解决方法
由于您只是克隆了一个 repo,因此您只需要进行常规合并:
)
克隆后,master 分支已经被检出,你就已经拥有最新的 master 分支了。
,git merge
将当前本地分支与您在命令行中提供的任何分支合并。你不能真正合并上游分支。因此,在您的示例中,您将 priv/dev
和 origin/master
合并到本地 master
分支。相反,您需要合并这些分支的本地副本,然后将最终结果推送到上游仓库:
git clone <repo URL>
cd <repo dir>
git checkout <branch you want to merge into>
git merge <branch you want to merge>
git push
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。