Skip to content

Instantly share code, notes, and snippets.

@tommcfarlin
Last active August 24, 2021 20:35
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tommcfarlin/a22929625c320d985747a83de31c0618 to your computer and use it in GitHub Desktop.
Save tommcfarlin/a22929625c320d985747a83de31c0618 to your computer and use it in GitHub Desktop.
[Source Control] Removing Git Commit History (Both Local and Remote)
# First, review the history. (Gotta make sure you're going to roll back to the right place!)
$ git log --pretty=oneline --abbrev-commit
# Remove HEAD back to the commit prior to the one that has sensitive information
# and set equal to the last good commit.
$ git rebase -i HEAD~1
# Push the content to the remote repository and remove it from the history.
$ git push origin +<name of branch>
# If you want to review the history...
$ git log --pretty=oneline --abbrev-commit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment