Giter Site home page Giter Site logo

swipswaps / rename-github-default-branch Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dfm/rename-github-default-branch

0.0 1.0 0.0 22 KB

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

License: MIT License

Python 100.00%

rename-github-default-branch's Introduction

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.

A note about pull requests

This script will not change the target for open pull requests when the branch is renamed and open pull requests will continue to point at the branch that they were opened on. It is possible to change the target branch in the user interface and it is possible that this could be automated using the API, but I have not experimented with that yet.

rename-github-default-branch's People

Contributors

adrn avatar dfm avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.