Skip to main content

Command Palette

Search for a command to run...

How to remove all commit history in git?

Updated
1 min read
How to remove all commit history in git?
H

Huniko519@2024

Clone the project, e.g. myproject is my project repository:

git clone https://github.com/huniko519/myproject.git

Since all of the commits histories are in the .git folder, we have to remove it:

cd myproject

And delete the .git folder:

git rm -rf .git

Now, re-initialize the repository:

git init

git remote add originhttps://github.com/huniko519/myproject.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

Done...

More from this blog

S

Software Engineer : https://github.com/huniko519

13 posts

Huniko519@2024