other

Remove all commits and history with git commands

These git commands can be helpful if you want to remove git commits with their history.

# Clone the project - Replace below url with your repo or project url
git clone https://github/git_username/repo_name.git

cd myproject

# Remove .git folder to remove git management
rm -rf .git

# Now, re-initialize the repository:
git init
git remote add origin https://github.com/git_username/repo_name.git
git remote -v

# Add all the files and commit the changes:
git add --all
git commit -am "Initial commit"

# Force push update to the master branch of our project repository:
git push -f origin master
Was this helpful?