Reset a git remote (--bare) repo to 'Initial commit'

Sat Aug 6 05:30:09 2011

wipe git remote

I found a situation where I wanted to totally reset a remote repository and although deleting it and then recreating it using --bare usually does the trick, the server set up shared dependances that would have caused more trouble if I had done that. So the only option was to completely reset the repo and effectively wipe clean any past history.

In actual fact it is simpler than it sounds. Create a local repo using git init, add some files using git add * (where you can also replace the * with the particular name of a file/files). Commit the changes, i.e. git commit -m "Initial commit" and then add the remote url using git remote add origin remote_url_here.

Now all you have to do it push to the master branch of your remote to overwrite everything. However, simply using the command git push origin master will most likely fail due to the fact that content already exits. So here's what you do. Use git push --force.

That should give the desired results and you'll find that the existing remote will update and feel much fresher indeed. However, BE WARNED that this deletes everything as you'll see if you run git log on the remote.

Happy committing!

← back

Most recent posts

  1. Flashcards Maker - the app the helps you learn in a flash
  2. Convert Font Suitcase to TTF in 3 Easy Steps
  3. Rain or Shine - Weather Forecast Available Now!
  4. Getting around Apple's silly rules for iOS 10
  5. Localising App Names for iOS and Android

Search site:

Apps by

Click the app icons to see more info