git remove all commits


Create Orphan Branch – Create a new orphan branch in git repository. The newly created branch will not show in ‘git branch’ command.

git checkout --orphan temp_branch

Add Files to Branch – Now add all files to newly created branch and commit them using following commands.

git add -A
git commit -am "the first commit"

Delete master Branch – Now you can delete the master branch from your git repository.

git branch -D master

Rename Current Branch – After deleting the master branch, let’s rename newly created branch name to master.

git branch -m master

Push Changes – You have completed the changes to your local git repository. Finally, push your changes to the remote (Github) repository forcefully.

git push -f origin master