Reset Git by Removing History

Reset Git

As you continue using Git, history keeps growing and repository size can increase. If the history is no longer needed, you can periodically remove it to reduce the repository size.

First, go to the repository and remove the existing history.

$ rm -rf .git

Initialize Git. After initialization, a new .git directory is created.

$ git init

Add all files.

$ git add .
or
$ git add -A

Then commit.

$ git commit -m "Initial commit"

Connect the repository.

$ git remote add origin {repository address}

Force push with the --force option.

$ git push -u --force origin master