Home > Enterprise >  Commit File to RollBack - Heroku
Commit File to RollBack - Heroku

Time:10-18

I am needing to commit a file to a rolled back commit on Heroku. I am currently running a rollback after a bug caused issues on Master which we are fixing. However I need to update the app.js on the rolled back version. Is this possible?

CodePudding user response:

If you want to run a previous release but you need to make changes to it, you're not doing a rollback. A rollback runs the compiled application slug from the previous release; there is no way to change the code in that release.

You need to run from another branch. If your commit graph looks something like this:

o---o---o  [old-release]
         \
          o---o  [main]

and you want to go back to old-release but change something, you'll need to create a new branch off of old-release, make your changes there, commit them, and then deploy from that new branch.

One way to do this would be to

  1. Create the new branch with git checkout -b bug-fix old-release
  2. Make your changes
  3. Commit
  4. Deploy the bug-fix branch to Heroku by running git push bug-fix:main (or git push bug-fix:master if you are using master as your main branch)

This will build a whole new release.

Your commit graph will now look something like this:

          A  [bug-fix]
         /
o---o---o  [old-release]
         \
          o---o  [main]

You might choose to rebase your main development line onto the bug-fix branch:

            o---o  [main]
           /
          A  [bug-fix]
         /
o---o---o  [old-release]

Or cherry-pick the new commit into main:

          A  [bug-fix]
         /
o---o---o  [old-release]
         \
          o---o---A'  [main]

If you don't have an old-release branch you can use the Git hash instead of a branch name when creating the bug-fix branch, e.g. with git checkout -b bug-fix abcd1234.

  • Related