The commit history doesn’t make sense, and disk space is ridiculous for a project with a lot of moving parts. It’s time to start over and enforce commit message that reflect the underlying change in a short, precise manner.
It's time to nuke everything except current code.
cd git-repository
du -sh .git
cp .git/config .
rm -rf .git
git init
cp config .git
git add .
git commit -m "Initial commit after deleting the history"
git push -u --force origin master // or git push --mirror --force
du -sh .git
git checkout —orphan newBranch
git add -A # Add all files and commit them
git commit -m ‘Clear history’
git branch -D master # Deletes the master branch
git branch -m master # Rename the current branch to master
git push -f origin master # Force push master branch to github
git gc —aggressive —prune=all # remove the old files
Source: Make the current commit the only (initial) commit in a Git repository
Let’s get back to the state of the remote repository, This will clone the master main branch by default, use git clone -b branch-name
for something specific.
sudo rm -r git-repository
git clone https://github.com/bhdicaire/git-repository.git
cd git-repository