Skip to content

Deleting specific git commits #22821

Discussion options

You must be logged in to vote

Most likely you’ll need to look at the file path rather than commit messages to do that, the examples for git filter-branch describe (among other things) how to remove a file from history. Alternatively, if the history isn’t too complex, you could use git rebase to manually edit the relevant commits.

Two words of caution though:

  1. Either method will change all commits starting from the first one that needs to be modified. So if your repository is shared with others, they’ll all notice the change and have to manually accept it (or not). In that case you should carefully consider if you really want to rewrite history.
  2. If your repository is on Github and you’re trying to remove sensitive data…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants