views:

150

answers:

2

How to reset a remote and local GIT repository to remove all revisions, and start fresh with the current Head as initial commit.

+1  A: 

First, follow the instructions in this question to squash everything to a single commit. Then make a forced push to the remote:

$ git push origin +master

And optionally delete all other branches both locally and remotely:

$ git push origin :<branch>
$ git branch -d <branch>
Martinho Fernandes
+3  A: 

Completely reset?

1) Delete the .git directory locally. 2) Recreate the git repostory

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

3) 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
Computer Linguist
+1 Was my first thought too. You have to backup and restore any local configs you have though.
Martinho Fernandes
Still in the remote repo at GitHub, in the messages I see previous messages.
Priyank Bolia
but the commits are gone, and repository is reset. Can we remove those previous messages also in front of the filenames.
Priyank Bolia
Remove the remote repository directly on GitHub and recreate it there.
Bombe