一个项目可以在 Git 中有两个(或更多)“起源”吗?
我想将一个项目推送到两个 github和一个 Heroku服务器。
具体是在添加github仓库的时候出现这个错误:
$ git remote add origin https://github.com/Company_Name/repository_name.git
fatal: remote origin already exists.
最佳答案
您可以拥有任意数量的 Remote ,但您只能拥有一个名为“origin”的 Remote 。名为“origin”的远程没有任何特殊之处,除了它是 Git 在克隆现有存储库时创建的默认远程。您可以配置第二个远程,向该远程推送/从该远程 pull ,并设置一些分支以跟踪来自该远程而不是原始分支的分支。
尝试添加一个名为“github”的远程:
$ 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
关于git - 一个项目可以有多个来源吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11690709/