I load on git some project which contains some personal data. Now I changed all lines and commit it. Now I need to erase all commits except last one to prevent loosing personal data.
Given that your main branch is called master, and you want to remove all commits except the last one from your master:
git checkout --orphan tmp
git add . --all
git commit -m "Init."
git push origin tmp
git branch -D master
git push origin :master
git checkout -b master
git push origin master
git branch -D tmp
git push origin :tmp
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