[英]How to merge a git repository into a branch of another repository
I have a github repository XXX. 我有一个github存储库XXX。 I want to merge into a branch of repository YYY.
我想合并到存储库YYY的分支中。 After the merge, YYY should have a branch named XXX.
合并后,YYY应该有一个名为XXX的分支。 How can I do this?
我怎样才能做到这一点?
The following may work. 以下可能有效。
From repository YYY, run the following: 在存储库YYY中,运行以下命令:
git remote add XXX https://github.com/YourUsername/XXX.git
git fetch XXX
Now, you should have branches like XXX/master
and any other branches that were in repository XXX, prefixed with XXX/
. 现在,您应该拥有像
XXX/master
这样的分支以及存储库XXX中以XXX/
为前缀的任何其他分支。
If you want to merge, for example, XXX/master
and your current branch on YYY into a new branch called merged-from-XXX
, you can do this: 例如,如果要合并
XXX/master
和YYY上的当前分支到名为merged-from-XXX
的新分支中,可以执行以下操作:
git checkout -b merged-from-XXX
git pull XXX master
You will be prompted to make a merge commit and resolve any conflicts if necessary. 系统将提示您进行合并提交,并在必要时解决所有冲突。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.