Coder Social home page Coder Social logo

github-branch-renamer's Introduction

GitHub Branch Renamer

A tool to rename the master branch for an entire account at once.

Installation

macOS

Install with Homebrew.

brew install erbridge/tap/github-branch-renamer

Everything else

You're on your own, I'm afraid. Refer to the Brewfile for clues about required dependencies.

Usage

$ gbr
Rename the 'master' branch for an entire account at once.

This tool will find all repositories on GitHub belonging to an account that:

  - aren't forks
  - aren't archived or disabled
  - have their default branch set to 'master'

It will then rename the master branch to 'main' by default, and set that as the
default branch on GitHub instead of 'master'.

By default, the 'master' branch will be left untouched to prevent any accidental
data loss. If you'd like to delete those branches, set the '--delete' flag.

You must choose to either do a dry run ('--dry-run') or force the changes
('--force'). You must also specify one of '--org' or '--user' (but not both) to
select the account to collect repositories from.

USAGE
  gbr [flags]

FLAGS
  -u, --user string         The username to collect repositories in
  -o, --org string          The organization to collect repositories in
  -t, --team string         The team within the organization (optional)
  -b, --new-branch string   The new name for the master branch (defaults to
                              'main')
  -d, --delete              Delete the master branch from GitHub
  -n, --dry-run             Report what will happen, without making any changes
                               on GitHub
  -f, --force               Run for real, making changes on GitHub
  -l, --list                Print a list of all GitHub repositories that would
                               be changed and exit (implies a dry run)

Why?

The conversation about the origin of "master" as a term in technology has come back around again recently. It's clear that Git's default branch name, master, originated from a master-slave metaphor, and even if it didn't, it still has that connotation for some people. We should rename our branches to something else to reduce the harm our language causes.

Renaming branches can be a time consuming, manual process, especially if your repositories are counted in the hundreds. It would be preferable to automate as much of that as possible. This tool attempts to do that.

This tool is limited to existing repositories. Until Git changes its defaults, new repositories will still be created with a master branch. See Leigh Brenecki's post for how to override that default behaviour.

github-branch-renamer's People

Contributors

erbridge avatar lfdebrux avatar rjw1 avatar zeke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

github-branch-renamer's Issues

`-o pipefail` causes script to always fail

Release v0.2.1 no longer works for me, I just see

==> Collecting relevant repositories for 'lfdebrux'...

and then the script exits with status 1 and no message.

I believe the issue is the pipefail option, because removing it causes the script to run as expected.

Looking at the definition of PARAMS in

github-branch-renamer/gbr

Lines 152 to 161 in 6724bc5

PARAMS=$(
echo "$RESPONSE" |
grep -F Link: |
sed 's/Link: //' |
sed 's/, /\
/g' |
grep -F 'rel="next"' |
grep -o '\?.*>' |
sed -e 's/>$//'
)
I think this pipeline is expected to fail when there are no pages left to visit?

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.