简体   繁体   English

Git将master分支推送到辅助远程

[英]Git push master branch to secondary remote

I have an existing git repository hosted on my company's online git account. 我在我公司的在线git帐户上托管了一个现有的git存储库。 I now want to set up a second remote within my client's online git account. 我现在想在我客户的在线git帐户中设置第二个遥控器。 I want to keep my company's repository as the primary day-to-day means of sharing code and the client's one just with the master branch for the current releases. 我希望将我公司的存储库作为共享代码的主要日常工作方式,而将客户端的存储库与当前版本的主分支保持一致。

I have used 我用过

git remote add <clientName> <clientRepoUrl> 

to add the new remote in my git config file. 在我的git配置文件中添加新的远程。

I can use 我可以用

git push <clientName> --all # pushes up the repo and its refs for the first time

to push the whole repo to the new remote. 把整个仓库推到新的遥控器上。

But what if I omit the --all parameter? 但是,如果省略--all参数怎么办? How will the merge commits to the master branch show up? 合并提交给主分支的方式如何显示? Will this actually work properly? 这实际上会正常工作吗?

But what if I omit the --all parameter? 但是,如果省略--all参数怎么办?

You can simply push only master ( git push <clientName> master ) to the second remote repo. 您只需将mastergit push <clientName> mastergit push <clientName> master第二个远程git push <clientName> master即可。
That will include all commits accessible from master , including the merge commits parents. 这将包括所有可从master访问的提交,包括merge commit parent。

x--x--x--x--M --x (master)
    \      /
     y----y       (branchY)

Pushing master only would push y commits, even though the reference branchY itself would not be pushed. 仅推送master将推送y提交,即使引用branchY本身不会被推送。

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

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