How to reset Heroku app and re-commit everything?

前端 未结 9 2082
傲寒
傲寒 2020-12-07 09:57

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 reco

相关标签:
9条回答
  • 2020-12-07 10:34

    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

    0 讨论(0)
  • 2020-12-07 10:39

    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.

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

    good luck

    0 讨论(0)
  • 2020-12-07 10:40

    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:

    git push heroku +master
    

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

    0 讨论(0)
  • 2020-12-07 10:42

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

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

    puts `git push -f git@heroku.com:#{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

    But I don't recommend it for newcomers :)

    0 讨论(0)
  • 2020-12-07 10:42

    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.

    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.

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

    If you have logs from the git push heroku please post them.

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

    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 heroku after your checkout?

    0 讨论(0)
  • 2020-12-07 10:47

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

    1. Run 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:

    1. git push heroku master -a APPNAME

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

    0 讨论(0)
提交回复
热议问题