Steps to clear out or reset the history of a git repository
Resetting and clear out a repository will completely erase your code and all repository history. If you need this data, make a backup now before proceeding.
There are some approached out there on StackOverflow like remove the .git folder, I've tried them never worked. If you have access to your remote repository settings you can just drop the remote branch but remote repository needed to have a special settings for that.
receive.denyDeleteCurrent would do that.
I don't have access to my remote repo configs so not going to do that.
I followed the following steps.
- If you already have the repository initialized then remove the .git folder.
rm -rf .git
- Re-create the repo with only current content.
git init git add . git commit -m "Initial commit"
- Now add the remote origin Git repository
git remote add origin [repo_address]
- Push the changes to the remote repository.
© Heshan Wanigasooriya.RSS
git push --mirror --force
🍪 This site does not track you.