克隆没有历史记录的 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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 10:58:08  来源:igfitidea点击:

Clone git repository without history?

git

提问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 --depthoption 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 .gitdirectory, 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

回答by Inder Kumar Rathore

Use the --depthoption in git clone:

使用中的--depth选项git clone

--depth <depth>Create a shallow clone with a history truncated to the specified number of revisions.

--depth<depth>创建一个浅层克隆,其历史记录被截断为指定的修订数量。

Usage: git clone --depth 1 <remote_repo_url>

用法: git clone --depth 1 <remote_repo_url>