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.

5

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.