git 将不同的分支推送到 Heroku

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

Push different branch to Heroku

githeroku

提问by tommyd456

Just finised work on my otherbranch. Now I need to test that this works on Heroku before I merge with the masterbranch.

刚刚在我的other分支上完成了工作。现在我需要在与master分支合并之前测试这是否适用于 Heroku 。

Is it possible to push the otherbranch to Heroku and it replace the contents of my last push which was from the masterbranch?

是否可以将other分支推送到 Heroku 并替换我上次推送的来自master分支的内容?

回答by amgaera

Yes, pushing to a branch named differently that your current one is possible using the syntax:

是的,可以使用以下语法推送到与您当前的分支名称不同的分支:

git push heroku other:master

This tells Git to push the contents of your otherbranch to the masterbranch on the herokuremote. Keep in mind that you may have to force push if there are commits on heroku/masterthat don't appear in your otherbranch.

这告诉 Git 将other分支的内容推送到远程master分支heroku。请记住,如果有heroku/master未出现在您的other分支中的提交,您可能必须强制推送。

For more information have a look at the documentation of the <refspec>optionto git push.

欲了解更多信息,有一个看的的文件<refspec>选项git push

回答by Ashad Nasim

git push -f heroku otherBranch:master

The -f (force flag) is recommended in order to avoid conflicts with other developers' pushes. Since you are not using Git for your revision control, but as a transport only, using the force flag is a reasonable practice.

建议使用 -f(强制标志)以避免与其他开发人员的推送发生冲突。由于您没有将 Git 用于版本控制,而仅用作传输,因此使用 force 标志是一种合理的做法。

source :- offical docs

来源:-官方文档