Git: How to reset a remote Git repository to remove all commits?

git, version-control

Solution

Completely reset?

Delete the `.git` directory locally.

Recreate the git repostory:

$ cd (project-directory)
$ git init
$ (add some files)
$ git add .
$ git commit -m 'Initial commit'

Push to remote server, overwriting. Remember you're going to mess everyone else up doing this … you better be the only client.

$ git remote add origin <url>
$ git push --force --set-upstream origin master

Problem

How can I reset a remote and local Git repository to remove all commits? I would like to start fresh with the current Head as the initial commit.

Original source

Related problems