跳转到主要内容

克隆/更新所有用户/组织的GitHub仓库

项目描述

ghcloneall

https://github.com/mgedmin/ghcloneall/workflows/build/badge.svg?branch=master https://ci.appveyor.com/api/projects/status/github/mgedmin/ghcloneall?branch=master&svg=true

这是一个脚本,用于从GitHub克隆/更新用户/组织的所有仓库。

目标受众:大型项目集合的维护者(例如,ZopeFoundation成员)。

用法示例

首先 pip install ghcloneall

克隆所有mgedmin的vim插件

mkdir ~/src/vim-plugins
cd ~/src/vim-plugins
ghcloneall --init --user mgedmin --pattern '*.vim'
ghcloneall

克隆所有mgedmin的gists

mkdir ~/src/gists
cd ~/src/gists
ghcloneall --init --user mgedmin --gists
ghcloneall

克隆所有ZopeFoundation仓库

mkdir ~/src/zf
cd ~/src/zf
ghcloneall --init --org ZopeFoundation
ghcloneall

以下是上述内容的屏幕录像(运行的是稍旧版本,因此脚本名称不同)

asciicast

详细信息

功能

  • 克隆您本地没有的仓库

  • 获取您已经本地拥有的仓库的更改

  • 警告您关于本地更改和其他意外情况

    • 树中的未知文件(仅在实际模式中)

    • 已暂存但未提交的更改

    • 未提交(和未暂存的更改)

    • 检出非默认分支

    • 已提交但未推送到默认分支的更改

    • 指向意外位置的远程URL(仅在实际模式中)

您可以通过运行 ghcloneall --dry-run 来要求它不要更改磁盘上的任何文件,仅查找挂起的更改。这也会使检查更快!

概要

其他命令行选项

$ ghcloneall --help
usage: ghcloneall [-h] [--version] [-c CONCURRENCY] [-n] [-q] [-v]
                  [--start-from REPO] [--organization ORGANIZATION]
                  [--user USER] [--github-token GITHUB_TOKEN] [--gists]
                  [--repositories] [--pattern PATTERN] [--include-forks]
                  [--exclude-forks] [--include-archived] [--exclude-archived]
                  [--include-private] [--exclude-private] [--include-disabled]
                  [--exclude-disabled] [--init] [--http-cache DBNAME]
                  [--no-http-cache]

Clone/update all user/org repositories from GitHub.

options:
  -h, --help            show this help message and exit
  --version             show program's version number and exit
  -c CONCURRENCY, --concurrency CONCURRENCY
                        set concurrency level (default: 4)
  -n, --dry-run         don't pull/clone, just print what would be done
  -q, --quiet           terser output
  -v, --verbose         perform additional checks
  --start-from REPO     skip all repositories that come before REPO
                        alphabetically
  --organization ORGANIZATION
                        specify the GitHub organization
  --user USER           specify the GitHub user
  --github-token GITHUB_TOKEN
                        specify the GitHub token
  --gists               clone user's gists
  --repositories        clone user's or organisation's repositories (default)
  --pattern PATTERN     specify repository name glob pattern to filter
  --include-forks       include repositories forked from other users/orgs
  --exclude-forks       exclude repositories forked from other users/orgs
                        (default)
  --include-archived    include archived repositories
  --exclude-archived    exclude archived repositories (default)
  --include-private     include private repositories (default when a github
                        token is provided)
  --exclude-private     exclude private repositories
  --include-disabled    include disabled repositories (default)
  --exclude-disabled    exclude disabled repositories
  --init                create a .ghcloneallrc from command-line arguments
  --http-cache DBNAME   cache HTTP requests on disk in an sqlite database for
                        5 minutes (default: .httpcache)
  --no-http-cache       disable HTTP disk caching

配置文件

脚本在当前工作目录中寻找 .ghcloneallrc,其格式如下

[ghcloneall]
# Provide either github_user or github_org, but not both
# github_org = ZopeFoundation
github_user = mgedmin
pattern = *.vim
# Provide github token for authentication
# github_token = <my-github-token>
# You can also uncomment and change these if you wish
# gists = False
# include_forks = False
# include_archived = False
# Listing private repositories requires a valid github_token
# include_private = True
# include_disabled = True

您可以使用以下命令创建一个:ghcloneall --init --{user,org} X [--pattern Y] [--{include,exclude}-{forks,archived,private,disabled}] [--gists|--repos].

提示

为了获得最佳效果,请配置SSH持久连接以加速git pull操作 —— 在您的 ~/.ssh/config 文件中。

Host github.com
ControlMaster auto
ControlPersist yes
ControlPath ~/.ssh/control-%r@%h-%p

在我的笔记本电脑上,使用这种设置对382个ZopeFoundation仓库运行 git pull 大约需要80秒。

变更日志

1.11.0 (2022-10-27)

  • 添加对Python 3.10和3.11的支持。

  • 停止支持Python 3.6。

  • 修复了 ghcloneall --user ... --github-token ... --include-private 不包括任何私有仓库的问题(GH: #16)。

1.10.1 (2021-05-26)

  • 在确定仓库是否已更改时,使用GitHub配置的默认分支而不是假设默认分支是“master”。

1.10.0 (2021-04-10)

  • 允许使用GitHub令牌进行身份验证。

  • 在Python 2.7上依赖requests-cache < 0.6。

  • 添加对Python 3.9的支持。

  • 停止支持Python 3.5。

1.9.2 (2019-10-15)

  • 添加对Python 3.8的支持。

1.9.1 (2019-10-07)

  • 重用HTTP连接进行GitHub API请求。

1.9.0 (2019-09-06)

  • 现在可以克隆所有用户的gists。

  • 命令行参数:–gists, –repos。

1.8.0 (2019-08-28)

  • 默认情况下跳过分支和存档仓库。

  • 命令行参数:–include-forks, –exclude-forks。

  • 命令行参数:–include-archived, –exclude-archived。

  • 命令行参数:–include-private, –exclude-private。

  • 命令行参数:–include-disabled, –exclude-disabled。

  • 在与GitHub通信时使用自定义User-Agent头。

1.7.1 (2019-08-14)

  • 停止支持Python 3.3和3.4。

  • 添加测试套件。

  • 修复了Python 2中的AttributeError: ‘str’ object has no attribute ‘format_map’。

1.7.0 (2018-12-19)

  • 命令行参数:-q, –quiet

  • 修复了在^C时显示损坏的问题。

1.6.1 (2018-10-19)

  • 修复了Python 2中的TypeError: get() got an unexpected keyword argument ‘fallback’。

1.6 (2016-12-29)

  • 全面重命名

    • 将GitHub仓库重命名为 https://github.com/mgedmin/ghcloneall

    • cloneall.py 重命名为 ghcloneall.py

    • 将配置文件重命名为 .ghcloneallrc,并将配置部分重命名为 [ghcloneall]

  • 在^C时不要打印跟踪回溯(这在1.5版本中有所退步)。

1.5 (2016-12-29)

  • 作为 ghcloneall 发布到PyPI

  • 添加了Python 2.7支持

1.4 (2016-12-28)

  • 命令行参数:–user, –pattern, –init

  • .cloneallrc 加载(一些)选项

  • 默认情况下停止使用 --organization=ZopeFoundation,需要显式选项(或配置文件)

  • 将 clone_all_zf_repos.py 重命名为 cloneall.py

1.3 (2016-12-28)

  • 命令行参数:-c

  • 在从GitHub获取仓库列表时显示进度

  • 默认情况下并行更新仓库

  • 突出显示正在进行的项

  • 用红色突出显示失败的项

  • 调整进度条样式从 [=== ][###..]

  • 在^C时清除进度条

  • 优雅地处理git错误

  • 错误修复:-vv在工作树中存在未知文件时可能会失败

  • 错误修复:正确显示使用 –start-from 时的进度

  • 错误修复:如果没有已经运行的SSH控制主进程,脚本会挂起(10分钟)

  • 错误修复:–dry-run没有显示哪些仓库是新的

1.2 (2016-11-09)

  • 命令行参数:–dry-run, –verbose

  • 将HTTP响应缓存到磁盘上10分钟,以避免GitHub API速率限制

  • 关于忘记的未提交和暂存更改的报告

  • 警告关于本地(未推送)的提交

  • 警告关于被检出其他分支

  • 再次默认为SSH URL(使用SSH的ControlPersist时更快)

1.1 (2015-11-07)

  • 命令行参数:–version, –start-from, –organization

  • 输出格式:缩短存储库名称,总计数在最后

  • 使用ANSI颜色来指示更改

  • 在^C时不打印跟踪回溯

  • 默认为HTTPS URL

1.0 (2015-11-07)

  • 已从gist迁移到合适的GitHub存储库。

项目详情


下载文件

下载适用于您平台的应用程序。如果您不确定选择哪个,请了解有关安装包的更多信息。

源分布

ghcloneall-1.11.0.tar.gz (26.5 KB 查看散列

上传时间

构建分布

ghcloneall-1.11.0-py2.py3-none-any.whl (15.5 KB 查看散列

上传时间 Python 2 Python 3

支持