如何在 Heroku 上更改 Git 遥控器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6226846/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 11:05:15  来源:igfitidea点击:

How to change a Git remote on Heroku

githeroku

提问by Jon

I do not want to upload my app to the wrong domain.

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

How can I change the git master branch on git?

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

回答by Mauro

If you're working on the herokuremote (default):

如果您在heroku远程工作(默认):

heroku git:remote -a [app name]

If you want to specify a different remote, use the -rargument:

如果要指定不同的遥控器,请使用-r参数:

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

EDIT: thanks to Алексей Володько For pointing it out that there's no need to delete the old remote.

编辑:感谢 Алексей Володько 指出无需删除旧遥控器。

回答by Abizern

Assuming your current remote is named originthen:

假设您当前的遥控器已命名,origin则:

Delete the current remote reference with

删除当前的远程引用

git remote rm origin

Add the new remote

添加新遥控器

git remote add origin <URL to new heroku app>

push to new domain

推送到新域

git push -u origin master

The -uwill set this up as tracked.

-u所跟踪将此设置。

回答by Diego Santa Cruz Mendezú

This worked for me:

这对我有用:

git remote set-url heroku <repo git>

This replacement old url heroku.

这个替换旧的 url heroku。

You can check with:

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

git remote -v

回答by Felipe Sabino

You can have as many branches you want, just as a regular git repository, but according to heroku docs, any branch other than masterwill be ignored.

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

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

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

Branches pushed to Heroku other than master will be ignored. If you're working out of another branch locally, you can either merge to master before pushing, or specify that you want to push your local branch to a remote master.

除了 master 之外,推送到 Heroku 的分支将被忽略。如果您在本地的另一个分支上工作,您可以在推送之前合并到 master,或者指定要将本地分支推送到远程 master。

This means that you can push anything you want, but you app at heroku will always point to the master branch.

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

But, if you question regards how to create branches and to work with git you should check this other question

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

回答by UA_

  1. View Remote URLs

    > git remote -v

  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. Remove Heroku remote URL

    > git remote rm heroku

  2. Set new Heroku URL

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

  1. 删除 Heroku 远程 URL

    > git remote rm heroku

  2. 设置新的 Heroku URL

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

And you are done.

你已经完成了。

回答by Hyman Stone

here is a better answer found through Git docs.

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

This shows what the heroku remote is:

这显示了 heroku 遥控器是什么:

$ git remote get-url heroku

$ git remote get-url heroku

Found it here: https://git-scm.com/docs/git-remoteAlso in that document is a set-url, if you need to change it.

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

回答by Akshata Dabade

If you have multiple applications on heroku and want to add changes to a particular application, run the following command : heroku git:remote -a appnameand then run the following. 1) git add . 2)git commit -m "changes" 3)git push heroku master

如果您在 heroku 上有多个应用程序并且想要向特定应用程序添加更改,请运行以下命令: heroku git:remote -a appname然后运行以下命令。1) git 添加。2)git commit -m "changes" 3)git push heroku master