跳到正文

git-clone-all

📦 克隆某个 GitHub 用户或组织的全部公开仓库

类别技术栈
语言TypeScript
CLIcommander
构建tsdown
测试Vitest
规范oxlint、oxfmt

安装#

sh
npm install -g git-clone-all

也可以不安装直接运行:

sh
npx git-clone-all <username>

需要 Node.js 22.13 及以上版本,以及 git。

使用说明#

text
Usage: git-clone-all [options] <username>
Clone all public repositories of a GitHub user or organization
Arguments:  username               GitHub user or organization
Options:  -V, --version          output the version number  -H, --https            clone by https (default)  -S, --ssh              clone by ssh  -d, --dir <dir>        directory to clone into (default: ".")  -c, --concurrency <n>  number of parallel clones (default: 4)  --no-forks             skip forked repositories  --no-archived          skip archived repositories  -p, --pull             pull repositories that already exist instead of                         skipping them  -h, --help             display help for command
sh
git-clone-all tlyboy                 # 克隆到当前目录git-clone-all tlyboy -d ~/i/tlyboy   # 克隆到指定目录git-clone-all tlyboy --ssh --no-forks --no-archivedgit-clone-all tlyboy --pull          # 更新已存在的仓库
  • 已存在的仓库会跳过,加 --pull 则拉取更新(仅 fast-forward)。
  • 默认 4 个仓库并行克隆。单个仓库失败不影响其他仓库,只要有失败,退出码就是 1。

认证#

未认证的 GitHub API 每小时限 60 次请求。token 依次取自 GITHUB_TOKEN、GH_TOKEN,以及已登录的 GitHub CLI(gh auth token)。只会列出公开仓库。

开发#

sh
pnpm installpnpm buildpnpm testpnpm lintpnpm formatpnpm typecheck

发版#

sh
pnpm release

bumpp 会升级版本号、提交、打 tag 并推送。tag 会触发 release workflow,通过 trusted publishing 把包提交到 npm 等待审核(自动附带 provenance),并用 changelogithub 创建 GitHub Release。维护者在 npmjs.com 包页面的 Staged Packages 标签中用 2FA 批准后(或执行 npm stage approve <stage-id>),新版本才会正式发布。

使用许可#

MIT © tlyboy