git 如何重置 Heroku 应用程序并重新提交所有内容?

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

How to reset Heroku app and re-commit everything?

ruby-on-rails-3githeroku

提问by bruno077

I'm building an application which I'm also testing in Heroku. I ran into some problem today and had to rollback one commit in my local git repo, but Heroku now won't recognize my changes saying that "everything is up to date".

我正在构建一个应用程序,我也在 Heroku 中测试该应用程序。我今天遇到了一些问题,不得不回滚我本地 git 存储库中的一个提交,但是 Heroku 现在无法识别我的更改,说“一切都是最新的”。

So, running

所以,运行

git push heroku master

heroku responds with

heroku 回应

Everything up-to-date

which isn't true.

这不是真的。

UPDATE: Things I've tried

更新:我尝试过的事情

git push -f heroku master
git push --force heroku master
git push heroku +master
git push --force heroku +master

Did some changes in the source code and then

在源代码中做了一些更改,然后

git add.
git commit -a -m "Message" #(Then this commit shows in my git explorer)
git push heroku master #Everything up-to-date

采纳答案by oma

Sounds weird. Maybe try pushing a different branch would do?

听起来怪怪的。也许尝试推动不同的分支会怎样?

git branch production
git checkout production
#do some code changes
git commit -am "some desperate code changes to try fix heroku"
git push heroku production:master

Creating a new production branch is what I want you to test. Besides, it's nice to have a production branch that you can use to deploy.

创建一个新的生产分支是我想让你测试的。此外,拥有一个可用于部署的生产分支也很好。

If it doesn't work, then I think the problem runs deeper and you need help from heroku.

如果它不起作用,那么我认为问题会更严重,您需要 heroku 的帮助。

EDIT: Add the heroku releases addontoo. Rolling back is as easy as heroku rollback

编辑:也添加heroku 发布插件。回滚就这么简单heroku rollback

回答by Rob Davis

This doesn't work in all situations, but if your local repo has diverged from the Heroku repo such that git can't figure out how to reconcile the two -- like if you rebased your local branch after it was pushed to Heroku -- you can force a push by putting a plus sign + before the ref, like this:

这并非在所有情况下都适用,但是如果您的本地存储库与 Heroku 存储库不同,以至于 git 无法弄清楚如何协调两者 - 就像您在将本地分支推送到 Heroku 后重新定位它一样 -您可以通过在 ref 之前放置一个加号 + 来强制推送,如下所示:

git push heroku +master

It may not work in your case, but it's worth a try.

它可能不适用于您的情况,但值得一试。

回答by Jeremy Thomas

This worked for me (from https://coderwall.com/p/okrlzg):

这对我有用(来自https://coderwall.com/p/okrlzg):

  1. Run heroku plugins:install https://github.com/lstoll/heroku-repo.git
  2. heroku repo:reset -a APPNAME
  1. heroku plugins:install https://github.com/lstoll/heroku-repo.git
  2. heroku repo:reset -a APPNAME

From there, the git repository has been "reset". Next, run:

从那里,git 存储库已被“重置”。接下来,运行:

  1. git push heroku master -a APPNAME
  1. git push heroku master -a APPNAME

to seed the git repository and re-deploy your app.

播种 git 存储库并重新部署您的应用程序。

回答by txomon

Supposing you rolled back one commit you remotely did, that previously existed. I think you should make:

假设您回滚了远程执行的一个提交,该提交先前存在。我认为你应该:

git merge heroku/master

If you just want to go forward

如果你只想向前

or:

或者:

git push --force heroku master

if you want to push that change

如果你想推动那个改变

回答by stephenmurdoch

I once had a similar problem and solved it by changing one char in my code and running git add/commit/push again. I imagine you've already tried that though.

我曾经遇到过类似的问题,并通过更改代码中的一个字符并再次运行 git add/commit/push 来解决它。我想你已经尝试过了。

Don't break the app, just add a comment to a CSS file or something and see if that does the trick

不要破坏应用程序,只需在 CSS 文件或其他内容中添加注释,看看是否可以解决问题

good luck

祝你好运

回答by Dahuchao

I had same problem and solved it by

我遇到了同样的问题并解决了

Git push origin HEAD:master

Git push origin HEAD:master

For you

为你

Git push heroku HEAD:master

Git push heroku HEAD:master

回答by Serge Seletskyy

After a while I came up to use rake task like this one deploy.rake

过了一会儿,我开始使用像这样的 rake 任务deploy.rake

It will standardize and speed up deployment especially when migrations should be implemented

它将标准化和加速部署,尤其是在应该实施迁移时

puts `git push -f [email protected]:#{APP}.git #{current_branch}`

As you see, option --force(or -f) is used for any push in order to ignore any conflicts with heroku's git repo

如您所见,选项--force(或-f)用于任何推送,以忽略与 heroku 的 git repo 的任何冲突

But I don't recommend it for newcomers :)

但我不建议新手使用它:)

回答by underScorePassionFruit

I had the same problem and I tried all the suggestions and didnot help. I had to run assets precompile locally and push, even though I did heroku run rake assets:precompile.

我遇到了同样的问题,我尝试了所有建议但没有帮助。我不得不在本地运行资产预编译并推送,即使我做了heroku run rake assets:precompile.

rake assets:precompile
git add .
git commit -am "local assets precompile"
git push heroku master

回答by colinross

Your heroku app will automatically reset when you upload a new version (slug) that boots. If the change you app in a way that makes it not boot, your apps dynos will continue to run the old version.

当您上传可启动的新版本 (slug) 时,您的 heroku 应用程序将自动重置。如果更改您的应用程序使其无法启动,您的应用程序 dynos 将继续运行旧版本。

In other words, when you deploy your app, it loads the slug (new source code) into a new dyno, and if the dyno loads the app properly, it will have that dyno replace the current dynos running your app.

换句话说,当您部署应用程序时,它会将 slug(新源代码)加载到新的 dyno 中,如果 dyno 正确加载应用程序,它将让该 dyno 替换运行您的应用程序的当前 dynos。

This might be your problem in not seeing any change...

这可能是您看不到任何变化的问题...

If you have logs from the git push herokuplease post them.

如果您有来自 的日志,git push heroku请发布它们。

Edit: git resetdeals with the git indexes and not the working tree or current branch.

编辑: git reset处理 git 索引而不是工作树或当前分支。

You have to them checkout the commit you reset to actually change the files-- how this interacts with heroku, I'm not so sure (never having rolled back a deploy to heroku yet, fingers crossed), but hope it helps. Maybe try doing a git push herokuafter your checkout?

您必须让他们检查您重置的提交以实际更改文件 - 这如何与 heroku 交互,我不太确定(从未将部署回滚到 heroku,手指交叉),但希望它有所帮助。也许尝试在git push heroku结帐后做一个?