我们有本地功能分支,github origin
分支以及Heroku staging
和production
远程分支。
由于本地功能已准备好供更多受众群体审核,我们希望将其推送到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.
我的一部分想要问题--force
,但远程的git push -f
是禁忌。我可以将这些变化作为"提示"但是,考虑到我们推进分期的分支通常是短暂的,可能与彼此没有什么关系,这似乎是不必要的和令人困惑的。
在Heroku上共享登台服务器的正确步骤是什么?
答案 0 :(得分:1)
您实际上在登台服务器上使用git作为部署机制,而不是版本控制。您已经在github上拥有真正的远程,因此只要您从不从中提取更改,我就不会看到有效的伤害推送到您的登台服务器。
由于两个原因,强行推动通常是一个坏主意。
您可以丢失提交。如果你强行推送到你的分支前面的遥控器,那么你前面的那些提交将会丢失。
你可以破坏其他开发者和#39;库。如果您强制推送到另一个开发人员已经拔出的远程分支,他们的分支将与远程分支不同步,并且可能难以恢复。
但是,在这种情况下,您只是将推送到存储库。你永远不会失去提交,因为上游永远不会超过任何特定的分支。此外,它永远不会被其他开发人员拉动。出于这些原因,在这种情况下可以强制推送。