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.
Asked
Active
Viewed 3,715 times
4
-
The best way is to merge all commits into one, which is answered by this question: http://stackoverflow.com/questions/7425725/how-to-merge-all-previous-commits-into-a-single-commit?rq=1 – Jon Cairns Mar 25 '13 at 14:43
-
finally, I just bought account to hide this code – Aleksandr Apr 23 '13 at 19:36
1 Answers
11
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 tmpgit add . --allgit commit -m "Init."git push origin tmp- On your remote git repo select tmp as main branch
git branch -D mastergit push origin :mastergit checkout -b mastergit push origin master- On your remote git repo select master as main branch
git branch -D tmpgit push origin :tmp
stevek-pro
- 13,672
- 14
- 81
- 134