簡體   English   中英

克隆沒有歷史記錄的 git 存儲庫?

[英]Clone git repository without history?

我想從 github 克隆存儲庫。 它有很多歷史,所以我想要沒有任何歷史的克隆。

是否可以在沒有歷史記錄的情況下克隆 git 存儲庫?

您可以使用值為 1 的--depth選項獲得淺克隆

git clone --depth 1 reponame.git

如果您想要更多提交歷史記錄,請根據需要增加該值以滿足您的需求。

克隆后,您可以刪除.git目錄,然后重新初始化 git 以生成一個全新的 repo。

$ git clone ...
$ cd path/to/repo
$ rm -rf .git
$ git init

git clone使用--depth選項:

--depth <depth>創建一個淺層克隆,其歷史記錄被截斷為指定數量的修訂。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM