gwalk 是一系列用于管理 Git 仓库的命令行小工具,帮助开发者对大批量的 Git 仓库进行日常维护。
Project description
gwalk
gwalk 是一系列用于管理 Git 仓库的命令行小工具,帮助开发者对大批量的 Git 仓库进行日常维护。
安装
1. pip
python -m pip install pygwalk
2. build from source
git clone https://github.com/ZeroKwok/gwalk.gitcd gwalkpython -m pip install .
使用
1. gl
gl.py 是 git pull 操作的快捷工具。
# 从远程仓库拉取代码并合并到当前分支, 等价于下面的命令
# git pull {origin 或 第一个remotes} {当前分支}
gl
# git pull {origin 或 第一个remotes} {当前分支} --rebase
gl --rebase
2. gcp
gcp.py 是用于执行 git commit 和 git push 操作快捷工具。
# 添加未跟踪的文件以及已修改的文件,并提交到远程仓库, 等价于下面的命令
# git add -u && git commit -m "fix some bugs" && git push
gcp "fix some bugs"
# 仅推送当前分支到所有远程仓库,不进行提交
gcp -p
3. gwalk
gwalk.py 是 gwalk 工具的主要组件,提供了以下功能:
- 列出目录下的所有 Git 仓库,支持过滤条件、黑名单、白名单和目录递归。
- 显示列出的仓库的状态信息,支持输出信息的简短或冗长格式。
- 在每个列出的仓库中执行一个操作。如运行自定义命令: 类似于子仓库操作
git submodule foreach 'some command'但更加灵活。
# 列出当前目录下所有的'脏'的 Git 仓库
gwalk
# 递归列出当前目录下所有的 Git 仓库
gwalk -rf all
# 在列出的每个仓库中执行命令: git pull origin
gwalk -rf all -a "run git pull origin"
使用技巧
# 在所有 gwalk 列出的仓库中, 执行 gl 工具(git pull)
gwalk -rf all -a run gl
# 在所有 gwalk 列出的仓库中, 执行 git push 操作 {ab} 表示 当前分支(ActiveBranch)
gwalk -rf all -a run git push second {ab}
# 批量手动处理(交互模式)
# 在列出的所有 '包含未提交的修改' 的仓库中, 启动一个 bash shell 来接受用户的操作
gwalk -rf modified --a bash
# 批量推送
# 在列出的所有 '包含未提交的修改 且 不再黑名单中' 的仓库中, 运行 gcp 工具, 推送当前分支到所有远程仓库
gwalk -rf modified --blacklist gwalk.blacklist --a "gcp -p"
# 批量打标签
# 在列出的所有 白名单 gwalk.whitelist 匹配的仓库中, 运行 git tag v1.5.0
gwalk -rf all --whitelist gwalk.whitelist -a run git tag v1.5.0
# 批量查看目录下所有仓库的最近3次提交
gwalk -f all -l none -a run "git log --oneline -n3"
# 批量替换 origin 远程仓库的地址, 从 github.com 替换成 gitee.com
# 在所有 gwalk 列出的仓库中, 执行自定义命令
gwalk -rf all -a run git remote set-url origin `echo \`git remote get-url origin\` | python -c "print(input().replace('github.com', 'gitee.com'))"`
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pygwalk-0.2.1.tar.gz
(13.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
pygwalk-0.2.1-py3-none-any.whl
(13.8 kB
view details)
File details
Details for the file pygwalk-0.2.1.tar.gz.
File metadata
- Download URL: pygwalk-0.2.1.tar.gz
- Upload date:
- Size: 13.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
320cf197bb17e20d13f74dc7fd7dc5de2653323e7d17e712b3bb4158d770b087
|
|
| MD5 |
51b6fcb4e053c52d62c35098b2591d4c
|
|
| BLAKE2b-256 |
70907dcddaac827c700dbbeadf70fce4133894ceeca337206ad0fb01975cdef3
|
File details
Details for the file pygwalk-0.2.1-py3-none-any.whl.
File metadata
- Download URL: pygwalk-0.2.1-py3-none-any.whl
- Upload date:
- Size: 13.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
638f0be8517f27aae900143f72ca46841a585ed4814a03527f2254f9a407e09f
|
|
| MD5 |
a7677b6678cb35b8398a6da98decf3a5
|
|
| BLAKE2b-256 |
1388d0da75ed5f928293d5a69d1569a377fdf89aee4550c190e189dbbfa8e887
|