All Projects → mheap → Github Default Branch

mheap / Github Default Branch

Licence: mit
Rename your default branch on GitHub

Programming Languages

javascript
184084 projects - #8 most used programming language

Labels

Projects that are alternatives of or similar to Github Default Branch

Neix
neix - a RSS/Atom feed reader for your terminal.
Stars: ✭ 128 (-3.03%)
Mutual labels:  cli
Madonctl
CLI client for the Mastodon social network API
Stars: ✭ 129 (-2.27%)
Mutual labels:  cli
Quickwall
Set latest wallpapers from Unsplash from the commandline
Stars: ✭ 131 (-0.76%)
Mutual labels:  cli
Check It Out
A command line interface for Git Checkout. See branches available for checkout.
Stars: ✭ 127 (-3.79%)
Mutual labels:  cli
Pipcorn
🍿 Watch YouTube videos on your Mac via CLI
Stars: ✭ 128 (-3.03%)
Mutual labels:  cli
Vidir
edit directory in $EDITOR (better than vim . with netrw)
Stars: ✭ 129 (-2.27%)
Mutual labels:  cli
Anirip
🎬 A Crunchyroll show/season ripper
Stars: ✭ 127 (-3.79%)
Mutual labels:  cli
Wmenu
An easy to use menu structure for cli applications that prompts users to make choices.
Stars: ✭ 130 (-1.52%)
Mutual labels:  cli
Node Appletv
A node module for interacting with an Apple TV (4th-generation or later) over the Media Remote Protocol.
Stars: ✭ 129 (-2.27%)
Mutual labels:  cli
Kui
A hybrid command-line/UI development experience for cloud-native development
Stars: ✭ 2,052 (+1454.55%)
Mutual labels:  cli
Bbrun
Run Bitbucket Pipelines locally
Stars: ✭ 127 (-3.79%)
Mutual labels:  cli
Awesome Wp Cli
A curated list of packages and resources for WP-CLI, the command-line interface for WordPress.
Stars: ✭ 129 (-2.27%)
Mutual labels:  cli
Slap
Painless shell argument parsing and dependency check.
Stars: ✭ 130 (-1.52%)
Mutual labels:  cli
Mhy
🧩 A zero-config, out-of-the-box, multi-purpose toolbox and development environment
Stars: ✭ 128 (-3.03%)
Mutual labels:  cli
Procs
A modern replacement for ps written in Rust
Stars: ✭ 2,435 (+1744.7%)
Mutual labels:  cli
Typex
[TOOL, CLI] - Filter and examine Go type structures, interfaces and their transitive dependencies and relationships. Export structural types as TypeScript value object or bare type representations.
Stars: ✭ 128 (-3.03%)
Mutual labels:  cli
Interact
A Golang utility belt for interacting with the user over a CLI
Stars: ✭ 129 (-2.27%)
Mutual labels:  cli
Jsonwatch
Track changes in JSON data from the command line
Stars: ✭ 130 (-1.52%)
Mutual labels:  cli
Natrium
A pre-build (Swift) script to alter your Xcode project at pre-build-time per environment, build configuration and target.
Stars: ✭ 131 (-0.76%)
Mutual labels:  cli
Arkade
Open Source Kubernetes Marketplace
Stars: ✭ 2,343 (+1675%)
Mutual labels:  cli

GitHub Default Branch

Rename your default branch on GitHub easily. By default it renames master to main, but is configurable using the --new and --old flags.

If provided with an --org, --user or (--org and --team) arguments, it will run on all repositories owned by that org, user or team. Alternatively, you can provide a --repo argument to edit a single repo. See Usage for more examples.

For each repo, this tool will:

  • Create a new branch at the same commit SHA as the old one
  • Update all open pull requests to point at the new branch
  • Update the default branch for the repo
  • Delete the old branch
  • Update known URL patterns in source files
  • Update any branch protections for $old to $new. (This does not work with patterns, it has to be an exact match)

Installation

npm install -g github-default-branch

Development

git clone https://github.com/mheap/github-default-branch.git
cd github-default-branch
npm ci

Authentication

Create a personal access token with the repo scope. This is the value for <token> in the examples.

If you don't want your token to be stored in your shell history, you can set GITHUB_TOKEN in the environment and that will be read instead

Usage

# Rename master to main
github-default-branch --pat <token> --repo user/repo

# Rename dev to develop
github-default-branch --pat <token> --repo user/repo --old dev --new develop

# Rename all repos owned by an org
github-default-branch --pat <token> --org my-org-name

# Rename all repos owned by a user
github-default-branch --pat <token> --user my-user

# Rename all repos owned by a team
github-default-branch --pat <token> --org my-org-name --team my-team-slug

Set DEBUG="ghdb*" as an environment variable to see debug information

Options

Flag Description Default
--pat GitHub API Token N/A
--old The name of the branch to rename master
--new The new branch name main
--repo The repo to update (format: user/repo) N/A
--user Update all repos owned by the provided user (example: my-user) N/A
--org Update all repos in the provided org (example: my-org-name) N/A
--team Update all repos in the provided team (example: my-team-name), only usable in combination with org parameter N/A
--dry-run Output log messages only. Do not make any changes false
--skip-forks Skips forked repositories false
--confirm Run without prompting for confirmation false

Skipping transforms

You might want to skip any of the available transforms (such as deleting the old branch). You can add --skip-[transform-name] to disable the transform e.g. --skip-delete-old-branch.

Available transforms

Transform Description
update-default-branch Set the default branch of the repo to $new
retarget-pull-requests Change the base for any open pull requests
retarget-draft-releases Change the target_commitish for any draft releases
branch-protection Update any branch protection rules to point at $new
delete-old-branch Delete the $old branch
github-pages Update GitHub Pages configuration

Pending transforms:

  • Copy branch protections instead of updating if --skip-delete-old-branch is used (#26)
  • Retarget draft releases (#30)

Replacements

Part of this script checks for the existence of files and updates their contents. Replacements are the mechanism for these updates.

How it Works

Each .js file in the replacements folder is given a chance to run during the content updating step of the script. Each file in replacements is expected to export a function, that function receives all of the options that are available to the outmost script.

If there is nothing to replace, then the script moves on to the next replacement.

How to Add a Replacement

Add a file to replacements with a .js extension

Like this:

module.exports = function ({
  owner, // string - repo owner
  repo, // string - repo name
  old, // string - old branch name
  target, // string - new branch name
  octokit, // Octokit - oktokit instance
  verbose, // boolean - verbose flag
  isDryRun, // boolean - dry run flag
}) {
  // code goes here
  return {
    path: "<path to file in repo>",
    replacements: [
      {
        from: "<from string>",
        to: "<to string>",
      },
      {
        from: "<from string>",
        to: "<to string>",
      },
    ],
  };
};

The file with the path in your repo will have any line matching from be swapped out with to

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].