Reputation: 241
I have a rails app that I have deployed to Heroku. I commited with v269 (origin master), which was stable and did not have any issues. I made a few more commits and then discovered various errors that I was unable to fix despite my best effort. I rolled back to v269 and am now stuck.
I'd like to disregard all those commits past v269, somehow ensure my local files are synced with that (dev env), and not destroy my whole git history in the process. I have tried doing a git pull
for that Heroku release to see my diffs to fix the error but that wasn't successful. Git is so powerful but I don't think I've fully wrapped my head around it.
I have looked at other SO answers but ultimately was not able to move forward with the above problem. How to reset Heroku app and re-commit everything? Heroku - How can I undo a push on heroku?
I appreciate any help that can be provided.
Upvotes: 1
Views: 1075
Reputation: 462
Your task is to locate the code for v269, grab a copy of that code and then push it to heroku to update the HEAD.
Locate the number of the rollback version you are after by viewing previous releases in terminal. (The value after n indicates the number of entries you want to see. The last ~15 application edits show with "heroku releases")
heroku releases -n 7
Terminal will show the last number of application versions/releases you requested.
user@computer:~/dev/my-great-app$ heroku releases -n 7
=== my-great-app Releases
v271 Rollback to v269 [email protected] 2016/12/01 04:49:01 (~ 3h ago)
v270 Deploy 7234c83 [email protected] 2016/12/01 03:26:58 (~ 5h ago)
v269 Deploy 1367a4f [email protected] 2016/11/30 21:25:07 (~ 11h ago)
v268 Set RAILS_ENV config vars [email protected] 2016/11/30 13:12:18 (~ 22h ago)
v267 Deploy 4536b70 [email protected] 2016/11/16 18:16:58
v266 Deploy 731f37c [email protected] 2016/10/23 04:33:18
v265 Deploy 1fb79a6 [email protected] 2016/10/12 04:52:00
Pick the deployment you want to pull. (In this case I have chosen 1367a4f because v269 was the clean version of the application.)
git pull heroku 1367a4f
You now have a copy of your application from a heroku rollback version. To save this code, be certain to create a branch for it in your git environment. (If you are dead new at this, you could, for peace of mind, copy the entire directory and stash it somewhere, and copy relevant code back over your master branch, but this isn't a good practice. Please don't mark this answer down for suggesting a directory backup for those still fumbling a bit with git.)
Push your restored master branch to heroku.
git push heroku master
Upvotes: 1
Reputation: 716
You can revert your commits and re-submit your app.
git revert <commit1-hash> <commit2-hash> ...
And then re-submit your app to heroku's production
Upvotes: 0