Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete all Git Commit History

Tags:

I am trying to fetch a repo from Github, revert a tag in past, push it to another remote with deleting all history. I can do everything with below except deleting all commit logs. What I am missing?

git clone https://github.com/user/user-repo.git cd user-repo git reset --hard tags/v2.0 git remote add stash ssh://git@myserver:7999/myproject/user-repo.git git push --force stash master 
like image 488
noway Avatar asked Feb 19 '13 23:02

noway


People also ask

Is it possible to remove commit history github?

If you commit sensitive data, such as a password or SSH key into a Git repository, you can remove it from the history. To entirely remove unwanted files from a repository's history you can use either the git filter-repo tool or the BFG Repo-Cleaner open source tool.


2 Answers

I thought what you want is a repo like a new one, so deleting the .git/ directory and re-initing it will be more simple.

git clone https://github.com/user/user-repo.git cd user-repo git reset --hard tags/v2.0  rm -rf .git/ git init git add . git commit -m 'first commit'  git remote add stash ssh://git@myserver:7999/myproject/user-repo.git git push --force stash master 
like image 185
pktangyue Avatar answered Sep 19 '22 12:09

pktangyue


You can use git merge --squash to squash all commits into one and then push it.

like image 20
wRAR Avatar answered Sep 20 '22 12:09

wRAR