如何删除GIT存储库中的所有内容? [英] How to delete everything inside GIT repository?
问题描述
如何从GIT存储库中删除所有内容,以便没有人能看到任何历史记录?
如果您问我为什么要这么做。出于安全考虑,我需要保护代码到另一台服务器上。 您的远程存储库。请确认这是您继续操作之前要做的事情。
-
创建一个新的空目录
-
在此目录中,
git init
-
git remote add remote remote-url
(用您要删除的远程仓库替换远程仓库) -
需要创建一个初始提交:
touch .empty
-
git add .empty
-
git commit
-
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.
Create a new, empty directory
In this directory,
git init
git remote add origin remote-url
(replace remote-url with the remote repo you will be deleting)Need to create an initial commit so:
touch .empty
git add .empty
git commit
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屋!