How do I delete a commit in the Github remote repository?

Asked

Viewed 74 times

1

I had never been in this situation, I have a public repository on Github and I need to delete the last 5 commits I did, both from the location and the remote that appears to everyone on Github. How can I do that?

1 answer

4


I think you got confused there. This command you posted works, but it is to delete branches, nay commits.

If you want to delete specific commits, you can use the interactive rebase: git rebase -i HEAD~6 This will let you edit the last 6 commits, and then just change the pick for d or drop in front of the commits you want to delete, quit rebase and give a git push -f.

  • Leo, thank you very much brother, you saved a lot! Only complementing if someone needs, to edit the rebase lines in VS use the "Insert" keyboard and leave in Insert in VS, after editing, to exit, press ESC and then type ":wq". (At least here it worked like this)

  • @Gabriel I didn’t specify how to get out of the pq rebase depends on the editor the guy has set up in Git, but this is msm :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.