Is there anyway for me to delete my github commit history? I don't want to lose all my commits, just the last 10 or so that were pushed to github. I can't seem to figure out how to do this.
If you commit sensitive data, such as a password or SSH key into a Git repository, you can remove it from the history.
By deleting line of the commit or writing drop instead of pick, you can remove the commit from history. Thus, we deleted a commit locally. To remove it from remote repository, we should push our changes to remote. The + sign before the name of the branch you are pushing, this tells git to force the push.
The easiest way to undo the last Git commit is to execute the “git reset” command with the “–soft” option that will preserve changes done to your files. You have to specify the commit to undo which is “HEAD~1” in this case. The last commit will be removed from your Git history.
Just pick the hash you want to go back to and in your clone do:
git reset --hard hash# git push -f origin branch
where branch
is the name of the branch you want to push. Voilà. Be carefully with the force push. You may want to copy your working directory until you are familiar with it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With