
新发布Sep 7, 2026
git-dumper v1.0.9
一个用于从网站转储Git仓库的工具
git-dumper
一个从网站转储 git 仓库的工具。
安装
可以通过 pip 轻松安装:
pip install git-dumper
使用
usage: git-dumper [options] URL DIR
Dump a git repository from a website.
positional arguments:
URL url
DIR output directory
optional arguments:
-h, --help show this help message and exit
--proxy PROXY use the specified proxy
-j JOBS, --jobs JOBS number of simultaneous requests
-r RETRY, --retry RETRY
number of request attempts before giving up
-t TIMEOUT, --timeout TIMEOUT
maximum time in seconds before giving up
-u USER_AGENT, --user-agent USER_AGENT
user-agent to use for requests
-H HEADER, --header HEADER
additional http headers, e.g `NAME=VALUE`
--client-cert-p12 CLIENT_CERT_P12
client certificate in PKCS#12 format
--client-cert-p12-password CLIENT_CERT_P12_PASSWORD
password for the client certificate
-b BRANCH, --branch BRANCH
additional branch name to check for (repeatable)
示例
git-dumper http://website.com/.git ~/website
免责声明
请自行承担使用本软件的风险!
您应当知道,如果您下载的仓库受到攻击者控制,这可能导致您的计算机被远程执行代码。
从源码构建
只需用 pip 安装依赖:
pip install -r requirements.txt
然后,直接运行:
./git_dumper.py http://website.com/.git ~/website
工作原理
该工具首先检查目录列表是否可用。如果可用,则只需递归下载 .git 目录(相当于用 wget 下载)。
如果目录列表不可用,它将使用多种方法尽可能多地查找文件。git-dumper 会逐步执行以下操作:
- 获取所有常见文件(
.gitignore、.git/HEAD、.git/index等); - 通过分析
.git/HEAD、.git/logs/HEAD、.git/config、.git/packed-refs等,尽可能多地查找引用(如refs/heads/master、refs/remotes/origin/HEAD等); - 通过分析
.git/packed-refs、.git/index、.git/refs/*和.git/logs/*,尽可能多地查找对象(sha1); - 递归获取所有对象,分析每次提交以查找它们的父提交;
- 运行
git checkout .来恢复当前工作树。