Delete old commits

Hi I want to know is there a way to delete old commits if so can someone help me do it please

You can do that if you’re willing to rewrite the repository history, which can cause trouble if you have shared the repository with anyone. See Git - Rewriting History, in particular the “Deleting a commit” section.

If you accidentally pushed sensitive data to GitHub and want to remove that there are some additional considerations. See Removing sensitive data from a repository, in particular the red warning box.

1 Like