一个Python脚本,用于使用API批量重命名GitHub存储库的默认分支
rename-github-default-branch的Python项目详细描述
默认的git/GitHub分支名称is oppressive terminology(more info)。 很容易更改分支名称for a single repository或for new repositories。 此脚本使您可以轻松地批量重命名GitHub存储库上的默认分支。在
使用
安装
要安装,请运行
python -m pip install rename-github-default-branch
然后,使用repo
权限范围创建一个GitHub.com personal access token,并设置环境变量:
重命名GitHub上的分支
然后,要将特定存储库的默认分支重命名为main
(您必须具有写入权限):
rename-github-default-branch -r dfm/rename-github-default-branch -t main
或者对于您拥有的所有回购(不包括fork):
rename-github-default-branch -t main
您还可以提供正则表达式来匹配存储库名称。例如:
rename-github-default-branch -t main -p "dfm/*" -p "exoplanet-dev/*"
更新本地分支
要更新本地存储库,可以运行以下命令:
git fetch origin main git checkout -b main origin/main git branch -D master
其中main
是新默认分支的名称,origin
是git远程的名称。在
- 项目
标签: