如何删除GIT存储库中的所有内容? [英] How to delete everything inside GIT repository?

查看:150
本文介绍了如何删除GIT存储库中的所有内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从GIT存储库中删除所有内容,以便没有人能看到任何历史记录?



如果您问我为什么要这么做。出于安全考虑,我需要保护代码到另一台服务器上。 您的远程存储库。请确认这是您继续操作之前要做的事情。


  1. 创建一个新的空目录


  2. 在此目录中, git init


  3. git remote add remote remote-url (用您要删除的远程仓库替换远程仓库)


  4. 需要创建一个初始提交: touch .empty


  5. git add .empty


  6. git commit


  7. git push origin --mirror


如果有人克隆远程仓库,他们将克隆一个只包含 .empty 的小型仓库。请注意,虽然你的git refs将无法从任何提交中获得,但它们仍然存在于服务器上,直到服务器端运行 git gc 。如果您使用GitHub或BitBucket托管,则会定期执行此操作。但是,如果是这样的话,只需删除存储库。


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.

解决方案

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.

这篇关于如何删除GIT存储库中的所有内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆