Git push vs. git push heroku master

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4413681/
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-19 04:49:26  来源:igfitidea点击:

Git push vs. git push heroku master

gitgithubherokucommitpush

提问by sscirrus

I just moved from a pc laptop to a Mac, and I've noticed a curious difference in how my git commands respond.

我刚刚从 PC 笔记本电脑转移到 Mac,我注意到我的 git 命令响应方式存在奇怪的差异。

Before, I would do the following:

在此之前,我会执行以下操作:

git add .
git commit -m "These are my new changes"
git push # This would update my repo on github
{enter password}
git push heroku master # This would push to my app on heroku
{enter password}

Now, when I do git push, the app just deploys on Heroku without pushing to my Github repo.

现在,当我这样做时git push,该应用程序只是在 Heroku 上部署,而无需推送到我的 Github 存储库。

How can I ensure I'm updating both places?

我怎样才能确保我更新了两个地方?

Edit

编辑

Thanks for your two answers! I appreciate the clarification of the difference between git pushand git push heroku master, in that git pushis pushing towards origin, which in my case, it seems, is Heroku.

谢谢你的两个答案!我很欣赏对git push和之间差异的澄清,因为git push heroku mastergit push正在推动起源,在我的情况下,它似乎是 Heroku。

How can I change the settings so that they work as before? i.e. I want git pushto now push to my repo on Github, and I want git push heroku masterto push to Heroku. The former currently pushes straight to Heroku, bypassing Github completely.

如何更改设置以使其像以前一样工作?即我git push现在想推送到我在 Github 上的 repo,我想git push heroku master推送到 Heroku。前者目前直接推向 Heroku,完全绕过 Github。

回答by Ben Scofield

To get the behavior you want, you'll need to remove the existing remotes and re-add them:

要获得您想要的行为,您需要删除现有的遥控器并重新添加它们:

git remote show origin # copy down the heroku URL
git remote rm origin
git remote add origin [github URL]
git remote add heroku [heroku URL]

回答by Greg Hewgill

The git pushcommand by default pushes to a remote called origin. This usually points to the place where you cloned your repository from, but you can change it later.

git push默认情况下,该命令推送到名为origin. 这通常指向您从中克隆存储库的位置,但您可以稍后更改它。

The git remote showcommand will show a list of all remotes. Then, git remote show originand git remote show herokuwill detail how each is configured.

git remote show命令将显示所有遥控器的列表。然后,git remote show origingit remote show heroku将详细介绍如何每个被配置。

You can manage and change the URL for each remote using the git remotecommand.

您可以使用该git remote命令管理和更改每个遥控器的 URL 。

回答by ewall

Just using the command git push--that is, omitting the arguments--means that git is going to have to use the defaults, which would be your first remote repository (commonly named 'origin') as the destination, and your local master branch as the source. In your case, I'm guessing that you cloned the project from GitHub in the first place, which makes your default remote be GitHub.

仅使用命令git push——即省略参数——意味着 git 将不得不使用默认值,这将是您的第一个远程存储库(通常命名为“origin”)作为目标,而您的本地主分支为来源。在你的情况下,我猜你首先从 GitHub 克隆了项目,这使得你的默认远程是 GitHub。

When you specify the arguments git push heroku master, you are explicitly saying to push your local master branch to the remote named heroku -- thus, GitHub is not updated with this command.

当您指定参数时git push heroku master,您明确表示要将本地 master 分支推送到名为 heroku 的远程 - 因此,GitHub 不会使用此命令更新。

(Perhaps heroku was your first/default remote on the PC, and when you moved to the Mac the originremote was the clone from GitHub?)

(也许 heroku 是你在 PC 上的第一个/默认遥控器,当你移动到 Mac 时,origin遥控器是从 GitHub 克隆的?)