一个从网站转储 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 . 来恢复当前工作树。