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
- Create the new branch with
git checkout -b bug-fix old-release
- Make your changes
- Commit
- Deploy the
bug-fix
branch to Heroku by runninggit push bug-fix:main
(orgit push bug-fix:master
if you are usingmaster
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
.