Skip to content

Instantly share code, notes, and snippets.

@gregmark
Created September 29, 2021 20:35
Show Gist options
  • Save gregmark/95b40dec08ee8d125807b366de667692 to your computer and use it in GitHub Desktop.
Save gregmark/95b40dec08ee8d125807b366de667692 to your computer and use it in GitHub Desktop.
Git: roll back a commit using git show

Git: roll back a commit using git show

  1. Get a listing of the files in the commit you want to rollback:
  2. Get the commit hash for the commit before the one you want to "roll back"
  3. Write a script like this one:
#!/bin/bash

dir=core/modules

for X in cassandra elasticsearch tigergraph graph; do

    path=${dir}/${X}/main.tf

    git show 02c5afc:${path} > $path

done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment