Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Heroku:如何在Heroku上更改Git遥控器_Git_Heroku - Fatal编程技术网

Heroku:如何在Heroku上更改Git遥控器

Heroku:如何在Heroku上更改Git遥控器,git,heroku,Git,Heroku,我不想将我的应用程序上载到错误的域 如何更改git上的git主分支 您可以拥有任意数量的分支,就像常规git存储库一样,但是根据heroku文档,除了master之外的任何分支都将被忽略 分支被推到Heroku,而不是 主人将被忽略。如果你是 在当地的另一个分支机构工作, 您可以在之前合并到master 推送,或指定要 将本地分支推送到远程分支 大师 这意味着你可以推送你想要的任何东西,但你在heroku的应用程序将始终指向主分支 但是,如果您对如何创建分支和如何使用git有疑问,您应该检查,

我不想将我的应用程序上载到错误的域


如何更改git上的git主分支

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

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

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


但是,如果您对如何创建分支和如何使用git有疑问,您应该检查

,假设您当前的远程设备名为
origin
,那么:

使用删除当前远程引用

git remote rm origin
添加新的遥控器

git remote add origin <URL to new heroku app>

-u
将此设置为跟踪。

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

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

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

编辑:感谢Ацццццццццццццццццццц109

这显示了heroku遥控器的功能:

$git远程获取url heroku

在这里找到它: 如果您需要更改,该文档中还有一个设置的url。

这对我很有用:

git remote set-url heroku <repo git>

如果heroku上有多个应用程序,并且希望向特定应用程序添加更改,请运行以下命令: heroku git:remote-应用程序名 然后运行以下命令。 1) git添加。2) git提交-m“更改”3)git推送heroku主机

  • 查看远程URL

    >git-remote-v

  • herokuhttps://git.heroku.com/###########.git (获取)<您的Heroku远程URL 赫罗库https://git.heroku.com/############.git (推) 起源https://github.com/#######/#####.git (fetch)<如果您使用GitHub,那么这是您的GitHub远程URL 起源https://github.com/#######/#####.git (推)
  • 删除Heroku远程URL

    >git远程rm heroku

  • 设置新的Heroku URL

    heroku git:remote-a


  • 您已经完成了。

    我如何更改git主机?这是什么意思?通过
    更改git主机
    您的意思是更改文件,然后提交并推送到它?改名?你到底想做什么?刚刚看到你对这个问题的评论,你的远程系统有问题,而不是分支系统。。。检查@Abizern的答案:)是的。我已经创建了一个新的heroku应用程序:heroku create myapp。但我在heroku上有另一个应用程序。我只想将git master更改为新的应用程序。所以我可以说git push heroku大师。代码将被加载到新的应用程序中,而不是旧的应用程序。我如何知道我的源代码的名称可能存在重复?您能解释一下您在这里的意思吗
    the-u将设置为跟踪。
    谢谢@uDay意思是当你要求拉,它将知道获取和合并此branchI将更新此答案,以删除heroku remote(而不是git remote origin master)。只是遵循此方法,似乎是当前正确的方法。由于OP没有指定正确答案,此答案大体上是OP问题的答案,并且有更多内容与上面的“最上面的”答案相比,为什么这个答案仍然显示在较小的一致答案下面?谢谢。甚至不需要移除旧的git遥控器
    heroku git:remote——一个appname
    ——将很好地替换旧的。
    heroku git:remote -a [app name] -r [remote] 
    
    git remote set-url heroku <repo git>
    
    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)