“git push heroku master"是怎么做的知道推送到哪里以及如何推送到不同的存储库? [英] How does "git push heroku master" know where to push to and how to push to a different repo?

查看:17
本文介绍了“git push heroku master"是怎么做的知道推送到哪里以及如何推送到不同的存储库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

推送到 Heroku 上托管的存储库时,必须执行以下命令:

git push heroku master

herokumaster 在这个命令中表示什么?git 如何知道推送到哪里?(git路径)

另外,我不知道我可以使用 heroku rename 来重命名应用程序,所以之前,假设我使用应用程序名称 trytryheroku,现在我使用 heroku create real-thing 但是如果我推送,它仍然会推送到 trytryheroku ......有没有办法推送到真实的东西?

解决方案

'heroku' 部分是您设置的遥控器的名称 - 当您创建 heroku 应用程序时,它第一次创建了一个 git 远程调用 'heroku' 指向您的应用程序 - 如果您在项目中键入 'git remote',它将显示远程端点.没有什么可以限制您使用heroku"作为远程的名称 - 如果您的应用程序有多个环境,则您可能有名为 production 或 staging 的远程.

'master' 部分是您希望推送到远程的本地分支.如果您在一个名为myfeature"的功能分支中进行开发,并且您想将其部署到 heroku,您可以这样做;

git push heroku myfeature:master

这里的附加 :master 是说将我本地的 myfeature 分支推送到远程的 master 分支 - 注意:heroku 只能从 master 分支部署.

如果您重命名应用程序,heroku git remote url 将更改 - 执行 git remote -v 这将显示您的应用程序正在使用的 git repo,您​​可能需要删除旧的 herokuorigin 并添加新的,git remote rm heroku 然后 git remote add heroku git@newgitpathfromcontrolpanel

要了解有关 Git 的更多信息,我会推荐这本

When pushing to a repository hosted on Heroku one must execute the following command:

git push heroku master

What do heroku and master indicate in this command? How does git know where to push to? (the git path)

Also, I didn't know I can use heroku rename to rename an app, so before, say I was using the app name trytryheroku and now I use heroku create real-thing but if I push, it still pushes to trytryheroku... is there a way to push to real-thing instead?

解决方案

The 'heroku' part is the name of the remote that you have setup - when you create a heroku app the first time it creates a git remote call 'heroku' pointing at your application - if you type 'git remote' within your project it will show you the remote endpoints. There's nothing locking you into using 'heroku' as the name of the remote - if you have multiple environments for your application you may have remotes named production or staging for example.

The 'master' part is the local branch you wish to push to the remote. If you develop in a feature branch for example named 'myfeature' and you want to deploy that to heroku you would do;

git push heroku myfeature:master

the additional :master here is saying push my local myfeature branch into the master branch on the remote - note: heroku can only deploy from the master branch.

If you rename an app the heroku git remote url will change - do a git remote -v which will show you the git repo your app is using, you will probably need to delete your old heroku origin and add the new one, git remote rm heroku then git remote add heroku git@newgitpathfromcontrolpanel

To learn more about Git I would recommend this book

这篇关于“git push heroku master"是怎么做的知道推送到哪里以及如何推送到不同的存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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