1

How can I delete everything from GIT repository, so that no one can see any history?

If you ask why I want to do that. For security reasons, I need to protect the code into another server.

mohamede1945
  • 7,092
  • 6
  • 47
  • 61
  • probably something along the lines of going to the first commit, amending it to put nothing in it, then push --force. – njzk2 Feb 28 '14 at 17:58
  • See also http://stackoverflow.com/questions/18112966/how-to-delete-purge-remove-all-history-commits-references-branches-from-a-remote (How to delete/purge/remove all history/commits/references/branches from a remote Git repo?) – tobiasvl Feb 28 '14 at 17:59
  • Could someone give me detailed steps? Sorry, I'm new to GIT. – mohamede1945 Feb 28 '14 at 18:05
  • Possible duplicate of [How to delete/purge/remove all history/commits/references/branches from a remote Git repo?](http://stackoverflow.com/questions/18112966/how-to-delete-purge-remove-all-history-commits-references-branches-from-a-remote), and [Delete all files and history from remote Git repo without deleting repo itself](http://stackoverflow.com/q/5363857/456814). –  Apr 20 '14 at 18:31
  • Note that if you're doing this for **security** reasons, e.g. removing sensitive data, then all of that data will **still exist** on the remote repo as dangling commits, until garbage collection is run on the remote repo. –  Jul 22 '14 at 03:21

1 Answers1

3

THIS WILL DELETE ALL COMMITS AND HISTORY IN YOUR REMOTE REPOSITORY. MAKE SURE THIS IS WHAT YOU WANT TO DO BEFORE CONTINUING.

  1. Create a new, empty directory

  2. In this directory, git init

  3. git remote add origin remote-url (replace remote-url with the remote repo you will be deleting)

  4. Need to create an initial commit so: touch .empty

  5. git add .empty

  6. git commit

  7. git push origin --mirror

If anyone clones your remote repository, they will clone a tiny repository that only contains .empty. Note that while your git refs will be unreachable from any commit, they still exist on the server until git gc is run on the server end. If you're hosting with GitHub or BitBucket, this is done periodically. But, if that's the case, just delete the repository.

schumacher574
  • 1,081
  • 1
  • 14
  • 32
  • Note that if the original poster is doing this for **security** reasons, e.g. removing sensitive data, then all of that data will **still exist** on the remote repo as dangling commits, until garbage collection is run on the remote repo. –  Jul 22 '14 at 03:20