How to: Revert to a specific commit, no git commands necessary

Prerequisites:

  • Must be on a version that supports advanced deploy and have it enabled
  • Your Looker instance must be accessible from the public internet, or you must be able to curl to the instance from command line
  • Must use a non-looker hosted repository which you have credentials to access

Solution:

1 - In Looker’s Project Settings, enable “Advanced Deploy” and set a Webhook Secret. Copy the secret, you will need it in step 3.

2 - In Your Git Provider: Find the specific commit you would like to revert to in the commit history of the Production Branch

66cc8c0d-3948-4911-92a8-a30c4f59f548.png

Grab the commit SHA, eg e289a61, of the commit you would like to revert to. 

- Hit the SHA Advanced Deploy webhook using curl. 

curl -i -X POST -H "X-Looker-Deploy-Secret:<webhook_secret>" https://<instance.url.com>/webhooks/projects/<project_name>/deploy/ref/<ref_of_commit_to_revert_to>

- Re-enter Production in your project. Fin 🙂

Note: At this point, your local production code will now have been reverted to the specified commit. However, the `HEAD` of your remote production branch will have been unchanged. Thus, if you say, “Revert to Production” while in dev mode, your dev branch will pull from the faulty `HEAD` that you reverted in previous steps. To revert changes such that remote production’s `HEAD` is in sync with local production will require several additional steps, one of which will be to resolve a merge conflict:

5 - In your Git Provider, create a new branch from the specific commit you reverted local production to in steps 2-3

- In Looker, switch to that branch in the IDE, toggle Advanced Deploy OFF, and hit “Deploy to Production”. 

7 - You will now need to resolve a merge conflict

5 4 5,911
4 REPLIES 4

You can also replace steps 5 and 6 with this alternate method, which allows you to keep Advanced Deploy Mode enabled and get a local dev branch back up to date with local production: 

5. In your Git Provider, revert the production branch to the specific commit you reverted local production to in steps 2-3.

6.  In Looker, you can create a new shared branch from the production branch to continue working from the reverted production state. 

@goodgollymissmo’s method is better, because it avoids the merge conflict 

If you expect this to happen often, it seems much easier to use “Push Changes to Remote” in Looker instead of “Deploy to Production”.

Then you would create a Pull Request with your personal development branch and commit that to main.

Use the Revert button under Pull Requests to rollback the changes.

Not sure if this is the appropriate thread for this question, but thought I'd take a shot:

Is it possible to revert a shared branch back to production after committing changes? Looks to me like the "Revert To Production" option is only available on personal dev branches, but it has happened to me on a couple of occasions where I've mistakenly committed in the wrong branch (while working on separate features). 

Perhaps I'm missing something, but it would be super useful if I could just revert those commits in the shared branch where the mistake was made. 

Top Labels in this Space
Top Solution Authors