简体   繁体   English

克隆/只读 git 存储库的历史记录/日志

[英]Cloning / Reading only history /log of a git repository

Within a localy cloned git repository i can watch the history with在本地克隆的 git 存储库中,我可以使用

git log

In a small tool i do only need the history of a repository, not the code.在一个小工具中,我只需要存储库的历史记录,而不是代码。 Is there a way to clone a repository without the code (history only)?有没有办法在没有代码的情况下克隆存储库(仅限历史记录)?

Is there any other way to get the history only from a git repository.有没有其他方法可以仅从 git 存储库获取历史记录。

Thanks in advance提前致谢

Clone the repository with the --bare flag: 使用--bare标志克隆存储库:

git clone --bare ...

A "bare" repository in Git just contains the version control information and no working files (no tree) and it doesn't contain the special .git sub-directory. Git中的“裸”存储库 只包含版本控制信息而没有工作文件(没有树),并且它不包含特殊的.git子目录。 Instead, it contains all the contents of the .git sub-directory directly in the main directory itself. 相反,它直接在主目录本身中包含.git子目录的所有内容。

Read more in the documentation on it, or this helpfull page about setting up server environments using the option. 阅读有关它的文档或有关使用该选项设置服务器环境的有用页面的更多信息。

If you only want to view the history, you can use the partial clone feature with filtering out the blobs(file contents).如果您只想查看历史记录,您可以使用过滤掉 blob(文件内容)的部分克隆功能。

git clone --filter=blob:none YOUR_GIT_URL git clone --filter=blob:none YOUR_GIT_URL

Ref:参考:

  1. git clone --filter git clone --filter
  2. Get up to speed with partial clone and shallow clone 快速了解部分克隆和浅层克隆

Combining the --bare and --filter=blob:none options on clone gives you the full logs while omitting the objects thus minimizing space for commit history:在克隆上结合 --bare 和 --filter=blob:none 选项可为您提供完整的日志,同时省略对象,从而最大限度地减少提交历史记录的空间:

git clone --bare --filter=blob:none... git 克隆 --bare --filter=blob: 无...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM