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. Convert Font Suitcase to TTF in 3 Easy Steps
  2. Rain or Shine - Weather Forecast Available Now!
  3. Getting around Apple's silly rules for iOS 10
  4. Localising App Names for iOS and Android
  5. Today - Powerful To-Do App Now Available on iOS & Android

Search site:

Apps by Ubacoda.com

Click the app icons to see more info


Archives

Categories