简体   繁体   English

Heroku:git push分期local-branch:master

[英]Heroku: git push staging local-branch:master

We have local feature branches, a github origin branch and Heroku staging and production remote branches. 我们有本地功能分支,github origin分支以及Heroku stagingproduction远程分支。

As local features become ready for review by a larger audience we'd like to push them to staging : 作为地方特色由更多的观众评审准备就绪,我们希望他们推到staging

$ git push staging local-branch-name:master
Fetching repository, done.
To git@heroku.com:app-staging.git
 ! [rejected]        local-branch-name -> master (non-fast-forward)
error: failed to push some refs to 'git@heroku.com:app-staging.git'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and integrate the remote changes
hint: (e.g. 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

Part of me wants to --force the issue but git push -f to a remote is taboo. 我的一部分希望--force问题,但是git push -f到远程是禁忌。 I could pull in the changes as the "hint" says but given that the branches we push into staging are often short lived and may have little to do with each other this seems like it would be unnecessary and confusing. 我可以按照“提示”中的说明进行更改,但是鉴于我们推送到分阶段的分支通常是短暂的,并且彼此之间几乎没有关系,这似乎是不必要和令人困惑的。

What is the proper procedure for sharing a staging server on Heroku? 在Heroku上共享登台服务器的正确程序是什么?

You're essentially using git on your staging server as a deployment mechanism, not for version control. 本质上,您是在登台服务器上将git用作部署机制,而不是用于版本控制。 You already have your real remote on github, so I don't see the harm in force pushing to your staging server as long as you never pull changes from it . 您已经在github上拥有了真正的远程服务器,因此,只要您从未从中拉出更改,就不会看到强行将其推送到登台服务器的危害。

Force pushing is typically a bad idea for two reasons. 强制推送通常是一个坏主意,原因有两个。

  1. You can lose commits . 您可能会丢失提交 If you force push to a remote that is ahead of your branch, those commits ahead of yours will be lost. 如果您强行推送到分支机构前面的远程服务器,那么那些在您分支机构之前的提交将丢失。

  2. You can mangle other developers' repositories. 您可以破坏其他开发人员的存储库。 If you force push to a remote branch that another developer has already pulled, their branch will be out of sync with the remote and it could be difficult to recover. 如果您强制推送到另一个开发人员已经拉过的远程分支,则他们的分支将与远程​​不同步,并且可能很难恢复。

However, in this case you are only pushing to the repository. 但是,在这种情况下,您只是送到存储库。 You will never lose commits because the upstream will never be ahead of any particular branch. 您将永远不会丢失提交,因为上游永远不会在任何特定分支之前。 Also, it is never pulled by other developers. 而且,它永远不会被其他开发人员拉扯。 For those reasons, it is ok to force push in this case. 由于这些原因,在这种情况下可以强制推动。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM