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.

Source Distribution

rename_github_default_branch-0.0.2.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file rename_github_default_branch-0.0.2.tar.gz.

File metadata

  • Download URL: rename_github_default_branch-0.0.2.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1.post20200604 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

File hashes

Hashes for rename_github_default_branch-0.0.2.tar.gz
Algorithm Hash digest
SHA256 b684932a2e427029ed1fe8012ac5e7b3d449cb6cafab28315b4ede68092ff931
MD5 20cd5a4a2425ee98f02487b4447ca49f
BLAKE2b-256 e804df018846d5842bb79d4ce7ecd81e6cff514c4d01c9ea9f502b31650d7fb4

See more details on using hashes here.

File details

Details for the file rename_github_default_branch-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: rename_github_default_branch-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1.post20200604 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

File hashes

Hashes for rename_github_default_branch-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 bcf1ed647addf3d91d8598a56be04517b4a5beba8d8dcf17506178f7378210d9
MD5 6a444f03d5ec27060744870c53ff1b47
BLAKE2b-256 cddaef556f7ca621abb876803c5c1fba6e2be8443d5ad1e8b028094c516dbf38

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page