一个项目可以有多个来源? [英] Can a project have multiple origins?

查看:100
本文介绍了一个项目可以有多个来源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想将一个项目推送到 github 和一个 Heroku 服务器。

具体而言,添加github存储库时会出现此错误:

  $ git remote add origin https:// github。 com / Company_Name / repository_name.git 
致命:远程原点已存在。


解决方案

em>,但只能有一个名为origin的远程设备。被称为origin的远程程序并不是特别的,除非它是克隆现有存储库时由Git创建的默认远程程序。您可以配置第二个远程设备,从该远程设备进行推/拉,并设置一些分支来跟踪该远程设备的分支,而不是源。



尝试添加一个名为 github代替:

  $ git remote add github https://github.com/Company_Name/repository_name.git 

#push master to github
$ git push github master

将my-branch推送到github并将其设置为跟踪github / my-branch
$ git push -u github my-branch

#使一些现有的分支轨道github而不是原产地
$ git branch --set-upstream其他分支github / other-branch


Can a project have two (or more) "origins" in Git?

I would like to push a single project to both github and a Heroku server.

Specifically, this error appears when adding the github repository:

$ git remote add origin https://github.com/Company_Name/repository_name.git
fatal: remote origin already exists.

解决方案

You can have as many remotes as you want, but you can only have one remote named "origin". The remote called "origin" is not special in any way, except that it is the default remote created by Git when you clone an existing repository. You can configure a second remote, push to/pull from that remote, and setup some branches to track branches from that remote instead of origin.

Try adding a remote called "github" instead:

$ git remote add github https://github.com/Company_Name/repository_name.git

# push master to github
$ git push github master

# Push my-branch to github and set it to track github/my-branch
$ git push -u github my-branch

# Make some existing branch track github instead of origin
$ git branch --set-upstream other-branch github/other-branch

这篇关于一个项目可以有多个来源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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