由于快进,使用 git 部署到 heroku 不断被拒绝

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

Deploying to heroku with git keeps getting rejected due to fast-forwards

ruby-on-railsruby-on-rails-3githeroku

提问by AnApprentice

I keep getting the following fail with heroku + git...

我一直在使用 heroku + git 遇到以下失败...

$ heroku jammit:deploy --app XXXXXXXXXXX
===== Compiling assets...[OK]
===== Commiting assets...[OK]
===== Done...
===== Deploying assets for xxxxx-staging to heroku...
To [email protected]:XXXXXXXX.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to '[email protected]:xxx-staging.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again.  See the
'Note about fast-forwards' section of 'git push --help' for details.
[FAIL]
===== Done...
===== Deleting compiled assets...[OK]
===== Commiting deleted assets...[OK]
===== Done...
$ git pull
Already up-to-date.

Any ideas what I'm doing wrong or should be doing differently to allow for pushing without having to force a push?

任何想法我做错了什么或应该做不同的事情以允许推动而不必强制推动?

Thanks

谢谢

回答by iwasrobbed

Just force the commit every time you push and it will push it even if there are fast-forward commits. We do this in our development Heroku server all the time since we're all pushing different commits (some further behind than others).

每次推送时都强制提交,即使有快进提交,它也会推送它。我们一直在我们的开发 Heroku 服务器中这样做,因为我们都在推动不同的提交(有些比其他的更落后)。

git push -f [email protected]:picasso-staging.git

I don't use jammit for deploying, but you could probably get away with force pushing first and then running the jammit task second. Or check and see if jammit supports a force push flag of some sort.

我不使用 jammit 进行部署,但您可能可以先强制推送,然后再运行 jammit 任务。或者检查并查看 jammit 是否支持某种强制推送标志。

回答by dsmithco

git push -f REMOTE BRANCH:master #or just master

Force it! Replace REMOTE with your heroku remote name (git remote -vto view all remotes). Replace BRANCH with the branch you want to push or just put "master" for the master branch.

给力!将 REMOTE 替换为您的 heroku 远程名称(git remote -v以查看所有远程)。将 BRANCH 替换为您要推送的分支,或者只为 master 分支放置“master”。

回答by MrDanA

The problem is that changes have already been pushed and your commit is behind those newer pushes. I'm going to assume you have a master branch and your feature branch still, let's say it's called my_feature. You can do this and be okay:

问题是已经推送了更改,而您的提交落后于那些较新的推送。我将假设您有一个 master 分支并且您的功能分支仍然存在,假设它被称为my_feature. 你可以这样做并且没事:

git checkout master
git pull
git checkout my_feature
git rebase master
    (you may have to fix some conflicts here, if any are found)
git checkout master
git merge my_feature
git push heroku

You should remember to run any tests you have to make sure everything's good still.

您应该记住运行所有测试以确保一切正常。