克隆没有历史记录的 git 存储库?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30001304/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Clone git repository without history?
提问by Dilip Kumar
I wanted clone repository from github. It had lot of history, So i wanted clone without any history.
我想从 github 克隆存储库。它有很多历史,所以我想要没有任何历史的克隆。
Is it possible to clone git repository without history?
是否可以在没有历史记录的情况下克隆 git 存储库?
回答by mathematician1975
You can get a shallow clone using the --depth
option with value 1
您可以使用--depth
值为 1的选项获得浅克隆
git clone --depth 1 reponame.git
If you want more commit history, increase the value to meet your needs as required.
如果您想要更多提交历史记录,请根据需要增加该值以满足您的需求。
回答by Kjuly
After cloned, you can delete the .git
directory, then re-init the git to generate a totally new repo.
克隆后,您可以删除.git
目录,然后重新初始化git以生成一个全新的repo。
$ git clone ...
$ cd path/to/repo
$ rm -rf .git
$ git init