mohamede1945
mohamede1945

Reputation: 7198

How to delete everything inside GIT repository?

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.

Upvotes: 1

Views: 5507

Answers (1)

schumacher574
schumacher574

Reputation: 1129

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.

Upvotes: 3

Related Questions