问题
I incorrectly made a push to heroku and used heroku rollback to roll it back to a previous version. That worked fine in that my heroku app is now serving the rolled back version.
But when a colleague who had pulled the "corrupted" push tried to checkout the "correct" version after the rollback, his git checkout from master branch is giving him the "corrupted" version and not the rolled back version.
Any idea why Heroku rolled back the application but not the master git repo?
回答1:
Ideally you shouldn't be using Heroku to host your Git repo but:
The version that Heroku is running and the HEAD commit on the Git repo are two different things. When you push, that tells the Heroku railguns to compile HEAD and deploy it. When you rollback it tells the railguns to compile a slug for the previous commit. It doesn't do anything to the Git repo.
Therefore, after a rollback, Heroku is running HEAD -1 whilst the Git repo is untouched.
回答2:
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 v36 Rollback to v34 email@example.com 2016/12/01 04:49:01 (~ 3h ago) v35 Deploy 7234c83 email@example.com 2016/12/01 03:26:58 (~ 5h ago) v34 Deploy 1367a4f email@example.com 2016/11/30 21:25:07 (~ 11h ago) v33 Set RAILS_ENV config vars email@example.com 2016/11/30 13:12:18 (~ 22h ago) v32 Deploy 4536b70 email@example.com 2016/11/16 18:16:58 v31 Deploy 731f37c email@example.com 2016/10/23 04:33:18 v30 Deploy 1fb79a6 email@example.com 2016/10/12 04:52:00
Pick the deployment you want to pull. (In this case I have chosen 1367a4f because v34 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 copy, 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 but this isn't necessary. (Please don't mark this answer down for suggesting a directory backup for those still fumbling a bit with git.)
来源:https://stackoverflow.com/questions/9898286/heroku-rollback-didnt-update-the-head-remote-branch-did-it