Rui*_*how 2 python git http github
当你在一个新目录或者一个现有目录中执行时git init
,Git会创建一个.git
目录,几乎所有Git存储和操作的内容都位于该目录中。
如果要备份或者复制一个库,基本上就是把这个目录复制到其他地方。
现在,我只想.git
从 GitHub 下载目录包含内容:
.git
使用request通过Python语言下载文件。(我不想通过 git long 命令)如何从 GitHub 或我的私有 gitlib 找到 .git 目录以及如何下载它?
如果您只需要 .git 内容,您仍然需要使用 git 命令:
git clone --bare https://github.com/<user>/<repo>
Run Code Online (Sandbox Code Playgroud)
你将得到一个裸仓库,一个没有工作树并且只有 .git 内容的仓库
请参阅“克隆 git 存储库的 Python 方法”和gitpython-developers/GitPython
from git import Repo
Repo.clone_from(git_url, repo_dir, branch='master', bare=True)
Run Code Online (Sandbox Code Playgroud)
对于pygit2,使用pygit2.clone_repository
:
clone_repository(url, path, bare=True)
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2998 次 |
最近记录: |