Skip to main content

A Python script for bulk renaming the default branch of your GitHub repositories using the API

Project description

The default git/GitHub branch name is oppressive terminology (more info). It is easy to change the branch name for a single repository or for new repositories. This script makes it easy to rename your default branch on GitHub repositories in bulk.

Usage

Installation

To install, run

python -m pip install rename-github-default-branch

Then, create a GitHub.com personal access token with the repo permission scope and set the environment variable:

export RENAME_GITHUB_TOKEN=YOUR_PERSONAL_ACCESS_TOKEN

Renaming branches on GitHub

Then to rename the default branch to main for a specific repository (you must have write access):

rename-github-default-branch -r dfm/rename-github-default-branch -t main

Or for all the repos that you own (excluding forks):

rename-github-default-branch -t main

You can also provide regular expressions to match against the repository name. For example:

rename-github-default-branch -t main -p "dfm/*" -p "exoplanet-dev/*"

Updating local branches

To update your local repository, you can run the following:

git fetch origin main
git checkout -b main origin/main
git branch -D master

where main is the name of the new default branch and origin is the name of the git remote.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for rename-github-default-branch, version 0.0.3
Filename, size File type Python version Upload date Hashes
Filename, size rename_github_default_branch-0.0.3-py3-none-any.whl (5.5 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size rename_github_default_branch-0.0.3.tar.gz (5.4 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page