如何在Heroku上更改Git遥控器

时间:2011-06-03 12:01:49

标签: git heroku

我不想将我的应用上传到错误的域名。

如何在git上更改git master分支?

7 个答案:

答案 0 :(得分:154)

如果您正在使用heroku遥控器(默认):

heroku git:remote -a [app name]

如果要指定其他遥控器,请使用-r参数:

heroku git:remote -a [app name] -r [remote] 

编辑:感谢АлексейВолодько指出它没有必要删除旧的遥控器。

答案 1 :(得分:99)

假设您当前的遥控器名为origin,那么:

使用

删除当前的远程引用
git remote rm origin

添加新远程

git remote add origin <URL to new heroku app>

推送到新域名

git push -u origin master

-u会将其设置为跟踪。

答案 2 :(得分:3)

您可以拥有所需数量的分支,就像常规git存储库一样,但根据heroku文档,除master之外的任何分支都将被忽略。

http://devcenter.heroku.com/articles/git

  

除了之外,分支机构被推到了Heroku   大师将被忽略。如果你是   在当地的另一个分支机构工作,   你可以在之前合并到主人   推,或指定你想要的   将您的本地分支推送到远程   主

这意味着你可以推送任何你想要的东西,但你在heroku的应用程序总是会指向主分支。

但是,如果你质疑如何创建分支和使用git,你应该检查this other question

答案 3 :(得分:3)

这对我有用:

git remote set-url heroku <repo git>

此替代旧网址heroku。

您可以通过以下方式进行检查:

git remote -v

答案 4 :(得分:1)

这是通过Git文档找到的更好的答案。

这显示了heroku遥控器的内容:

$ git remote get-url heroku

在此处找到:https://git-scm.com/docs/git-remote 如果你需要更改它,那么该文档中还有一个set-url。

答案 5 :(得分:0)

如果heroku上有多个应用程序,并且想对特定的应用程序进行更改,请运行以下命令: heroku git:远程-应用名称 然后运行以下命令。 1)git添加2)git commit -m“ changes” 3)git push heroku master

答案 6 :(得分:0)

  1. 查看远程URL

    > git remote -v

    heroku  https://git.heroku.com/###########.git (fetch) < your Heroku Remote URL
    heroku  https://git.heroku.com/############.git (push)
    origin  https://github.com/#######/#####.git (fetch) < if you use GitHub then this is your GitHub remote URL
    origin  https://github.com/#######/#####.git (push)
  1. 删除Heroku远程URL

    > git remote rm heroku

  2. 设置新的Heroku URL

    > heroku git:remote -a ############

您已完成。