Skip to content

gr2m/rename-github-branch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

🚧🏗 THIS IS WORK IN PROGRESS

rename-github-branch

CLI to rename a branch on GitHub repositories

Usage

You need to create a personal access token with the "repo" scope: https://github.com/settings/tokens/new?scopes=repo

Replace <ACCESS TOKEN> below with the token you just created.

Rename branch for specific repository

npx rename-github-branch --token=<ACCESS TOKEN> --repo=gr2m/rename-github-branch

Rename branch for all repositories in an organization or account

npx rename-github-branch --token=<ACCESS TOKEN> --owner=gr2m

How it works

  1. Creates a new reference using the sha of the last commit of current_branch (POST /repos/:owner/:repo/git/refs)
  2. Updates the default branch of the repository (PATCH /repos/:owner/:repo)
  3. Updates branch protection to the new branch name if applicable (GraphQL mutation updateBranchProtectionRule)
  4. Look for open pull requests and update the base branch if it’s current_branch (PATCH /repos/:owner/:repo/pulls/:number)
  5. Delete current_branch (DELETE /repos/:owner/:repo/git/refs/:ref)

Motivation

I think master is a horrific term. git & GitHub should follow the lead of tech communities such as Django, Drupal and CouchDB and replace master with non-offensive term, such as latest. This library is meant to simplify the process of renaming branch names of GitHub repositories.

License

MIT

About

CLI to rename a branch on GitHub repositories

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published