GitHub CLI extension to show & rename the default branch.

Related tags

IDEs gh-extension
Overview

gh-default-branch

GitHub CLI extension to show & rename the default branch.

rename subcommand was inspired by this gist.

⚠️ Caution

The rename subcommand is missing some features.

If you want any of the following missing features, try to change the default branch name from the GUI.

See. https://github.com/github/renaming#renaming-existing-branches

  • Re-target any open pull requests
  • Update any draft releases based on the branch
  • Move any branch protection rules that explicitly reference the old name
  • Update the branch used to build GitHub Pages, if applicable
  • Show a notice to repository contributors, maintainers, and admins on the repository homepage with instructions to update local copies of the repository
  • Show a notice to contributors who git push to the old branch
  • Redirect web requests for the old branch name to the new branch name
  • Return a "Moved Permanently" response in API requests for the old branch name

Also see. https://github.com/cli/cli/issues/1215

Installation

$ gh extension install daido1976/gh-default-branch

Usage

# Show default branch
$ gh default-branch show
# Current default branch is "master"

# Rename default branch
$ gh default-branch rename main
# The following execution log will be output.
#
# === START: Rename from master to main ===
# $ git fetch origin master
# From https://github.com/daido1976/gh-default-branch
#  * branch            master     -> FETCH_HEAD
# $ git checkout -B main origin/master --no-track
# Switched to and reset branch 'main'
# $ git push -u origin main
# remote:
# remote: Create a pull request for 'main' on GitHub by visiting:
# remote:      https://github.com/daido1976/gh-default-branch/pull/new/main
# remote:
# remote: Heads up! The branch 'main' that you pushed to was renamed to 'master'.
# remote:
# To https://github.com/daido1976/gh-default-branch.git
#  * [new branch]      main -> main
# $ git remote set-head origin main
# Set HEAD to main
# $ gh api -X PATCH repos/daido1976/gh-default-branch -f default_branch=main
# Default branch is renamed to main!
# $ gh api -X PATCH repos/daido1976/gh-default-branch/pulls/2 -f base=main
# $ gh api -X PATCH repos/daido1976/gh-default-branch/pulls/1 -f base=main
# All PR's base branch are updated!
# $ git push --delete origin master
# To https://github.com/daido1976/gh-default-branch.git
#  - [deleted]         master
# === FINISH: Rename from master to main ===

Release

$ ./release.sh <version(e.g.`v0.1`)>
# And please update the tag version in `gh-default-branch` file to <version>.
You might also like...
👑 Show in-organization ranking of GitHub activities such as review count.

gh-ranking Show in-organization ranking of GitHub activities such as review count. Installation gh extension install yukukotani/gh-ranking Usage USAG

GitHub CLI extension to search some repos interactively.
GitHub CLI extension to search some repos interactively.

gh activity GitHub CLI extension to search some repos interactively. It's wrapper to build gh command provided by GitHub CLI, it could search more eas

Batch rename utility for developers
Batch rename utility for developers

nomino Batch rename utility for developers How to install Pre-Compiled You can download a pre-compiled executable for Linux, MacOS and Windows operati

RnR is a command-line tool to securely rename multiple files and directories that supports regular expressions
RnR is a command-line tool to securely rename multiple files and directories that supports regular expressions

RnR is a command-line tool to securely rename multiple files and directories that supports regular expressions. Features Batch rename files and direct

Rsre it's tool to rename file/directory

, Rust renamer Rsre it's tool to rename file/directory Zero dependencies 👀 Requirements Rust Nightly Install With Cargo # Install nightly rust rustup

Stacked branch management for Git
Stacked branch management for Git

git-stack Stacked branch management for Git Dual-licensed under MIT or Apache 2.0 Documentation About Installation Getting Started Reference FAQ Compa

🧠 A command-line utility for switching git branches more easily. Switch branches interactively or use a fuzzy search to find that long-forgotten branch name.
🧠 A command-line utility for switching git branches more easily. Switch branches interactively or use a fuzzy search to find that long-forgotten branch name.

git-smart-checkout A git command extension for switching git branches more efficiently. About Interactively switch branches or fuzzy search for that f

The [cain!] macro is a macro that rewrites sequential Rust branch statements into nested branches

Note! This crate is experimental and under development. It may include bugs that alter the behavior of your code in unexpected ways. You should review

🍹Branch and bound solution using Rust to calculate an optimal cocktail ingredient list of arbitrary length 🍸

Calculating an Optimal Cocktail Ingredient List Tom Explains the Problem You have 100 different ingredients You have 20 cocktails, each of which use 2

Automatically commit all edits to a wip branch with GPT-3 commit messages

gwipt Automatic work-in-progress commits with descriptive commit messages generated by GPT-3 Codex Never again worry about the tension between "commit

Rust-based replacement for the default Minecraft renderer

wgpu-mc 🚀 A blazing fast alternative renderer for Minecraft Intro WebGPU is a new web specification designed to provide modern graphics and compute c

Autodefault automatically makes your struct literals fill themselves with `..default()`

autodefault A library that automatically inserts ..Default::default() for you. The pitch Has this ever happened to you? #[derive(Debug, Default, Parti

zero runtime cost default arguments in rust

Default Arguments in Rust Enables default arguments in rust by macro in zero cost. Just wrap function with default_args! and macro with name of functi

A tool that switch default audio playback device on windows.

AudioSwitch A tool built by Rust that can switch default audio playback device on windows. How to use specify which device you want to use Execute it

Shellfirm - Intercept any risky patterns (default or defined by you) and prompt you a small challenge for double verification
Shellfirm - Intercept any risky patterns (default or defined by you) and prompt you a small challenge for double verification

shellfirm Opppppsss you did it again? 😱 😱 😰 Protect yourself from yourself! rm -rf * git reset --hard before saving? kubectl delete ns which going

Default implementation of the Wayland protocol for use with wl

Wayland An implementation of core Wayland interfaces and convenience functions for accelerating the development of Wayland clients and servers using t

⚡ A blazing fast alternative to the default Windows delete.
⚡ A blazing fast alternative to the default Windows delete.

Turbo Delete A blazing fast alternative to the default Windows delete. Turbodelete is a blazing fast alternative to the default Windows delete functio

Yet Another Kalman Filter Implementation. As well as Lie Theory (Lie group and algebra) on SE(3). [no_std] is supported by default.

yakf - Yet Another Kalman Filter Yet Another Kalman Filter Implementation, as well as, Lie Theory (Lie group, algebra, vector) on SO(3), SE(3), SO(2),

Cassandra DB native client written in Rust language. Find 1.x versions on https://github.com/AlexPikalov/cdrs/tree/v.1.x Looking for an async version? - Check WIP https://github.com/AlexPikalov/cdrs-async
Cassandra DB native client written in Rust language. Find 1.x versions on https://github.com/AlexPikalov/cdrs/tree/v.1.x Looking for an async version? - Check WIP https://github.com/AlexPikalov/cdrs-async

CDRS CDRS is looking for maintainers CDRS is Apache Cassandra driver written in pure Rust. 💡 Looking for an async version? async-std https://github.c

Comments
  • Feature Request: Add flag to minimize output to just show the branch name

    Feature Request: Add flag to minimize output to just show the branch name

    I love this extension but the one thing I would get the most use out of would be to have it return just the name of the default branch so that it can be used in other scripts.

    Example: gh default-branch show -name

    Expected output: main

    Currently: gh default-branch show

    Output: Current default branch is "main"

    In order to make use of this output additional work must be done to isolate only the name of the branch so that it can be used in terminal scripts.

    If this could be added it would make my day! 🥰

    opened by allen-mckenzie 2
  • Linux support

    Linux support

    Overview

    See. https://github.com/daido1976/gh-default-branch/issues/3

    Operation check

    See. https://github.com/cli/cli/blob/v2.10.1/docs/install_linux.md

    $ docker run --name ruby_bash --rm -it ruby bash
    root@xxx:/# uname -a
    Linux xxx 5.10.76-linuxkit #1 SMP Mon Nov 8 10:21:19 UTC 2021 x86_64 GNU/Linux
    root@xxx:/# cat /etc/issue
    Debian GNU/Linux 11 \n \l
    
    root@xxx:/# curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
    root@xxx:/# echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null
    root@xxx:/# apt update
    root@xxx:/# apt install gh
    root@xxx:/# gh extension install daido1976/gh-default-branch
    root@xxx:/# gh auth login
    root@xxx:/# cd home/
    root@xxx:/home# git clone https://github.com/daido1976/gh-default-branch.git
    root@xxx:/home# cd gh-default-branch/
    root@xxx:/home# gh default-branch show
    Current default branch is "main"
    

    Note

    • https://github.com/daido1976/gh-report/issues/1
    opened by daido1976 1
  • Fails to run with exec format error

    Fails to run with exec format error

    Running on up-to-date Ubuntu 21.10

    $ gh default-branch       
    /home/andy/.local/share/gh/extensions/gh-default-branch/gh-default-branch: line 19: /home/andy/.local/share/gh/extensions/gh-default-branch/bin/gh-default-branch-v0.1: cannot execute binary file: Exec format error
    /home/andy/.local/share/gh/extensions/gh-default-branch/gh-default-branch: line 19: /home/andy/.local/share/gh/extensions/gh-default-branch/bin/gh-default-branch-v0.1: Success
    
    $ file /home/andy/.local/share/gh/extensions/gh-default-branch/bin/gh-default-branch-v0.1
    /home/andy/.local/share/gh/extensions/gh-default-branch/bin/gh-default-branch-v0.1: Mach-O 64-bit x86_64 executable, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|PIE|HAS_TLV_DESCRIPTORS> 
    
    $ uname -a
    Linux tigara 5.13.0-25-generic #26-Ubuntu SMP Fri Jan 7 15:48:31 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
    
    opened by andypiper 1
  • Add `--name-only` option to show subcommand

    Add `--name-only` option to show subcommand

    Why

    See. https://github.com/daido1976/gh-default-branch/issues/5

    How

    • Introduce clap
    • Add --name-only option to show subcommand

    The output is as follows.

    $ gh default-branch -h
    gh default-branch 0.6.0
    GitHub CLI extension to show & rename the default branch
    
    USAGE:
        gh-default-branch <SUBCOMMAND>
    
    OPTIONS:
        -h, --help       Print help information
        -V, --version    Print version information
    
    SUBCOMMANDS:
        help      Print this message or the help of the given subcommand(s)
        rename    Rename default branch
        show      Show default branch
    
    $ gh default-branch show -h
    gh-default-branch-show
    Show default branch
    
    USAGE:
        gh-default-branch show [OPTIONS]
    
    OPTIONS:
        -h, --help         Print help information
        -n, --name-only    Show only the branch name (e.g. main)
    
    $ gh default-branch show
        Finished release [optimized] target(s) in 0.03s
    Current default branch is "main"
    
    $ gh default-branch show -n
    main
    
    $ gh default-branch show --name-only
    main
    

    Note

    • https://github.com/clap-rs/clap/blob/v3.1.18/examples/tutorial_derive/README.md
    opened by daido1976 0
Releases(v0.6.1)
Owner
Daido Shota
Daido Shota
Rust extension for Visual Studio 2017 with RLS support

Rust support for Visual Studio 2017 Preview Adds language support for Rust to Visual Studio 2017. Supports: code completion goto definition find all r

Zoey Riordan 111 Aug 4, 2022
crates is an extension aims to help people to manage their dependencies for rust (crates.io & TOML).

crates Hello Rust & VSCode lovers, This is crates, an extension for crates.io dependencies. Aims helping developers to manage dependencies while using

Seray Uzgur 164 Jan 4, 2023
Auto-Complete is an intelligent auto-completion extension for Emacs.

Auto-Complete is an intelligent auto-completion extension for Emacs. It extends the standard Emacs completion interface and provides an environment that allows users to concentrate more on their own work.

Emacs Auto-Complete 1.7k Dec 28, 2022
A native debugger extension for VSCode based on LLDB

Features Conditional breakpoints, function breakpoints, logpoints, Hardware data access breakpoints (watchpoints), Launch debuggee in integrated or ex

null 1.6k Dec 31, 2022
A brand-new language server for Typst, plus a VS Code extension

Typst LSP A brand-new language server for Typst. Features Syntax highlighting, error reporting, code completion, and function signature help Compiles

Nathan Varner 414 Apr 17, 2023
A CLI tool to launch vscode projects, which supports devcontainers.

vscli A CLI tool to launch vscode projects, which supports devcontainers. Features A shorthand for launching vscode projects Detects whether a project

Michael Lohr 7 Mar 20, 2023
🛡️ Automatically protect the default branch of new repositories in a GitHub organization

The Branch Autoprotector watches a GitHub organization and automatically protects the default branch in new repositories. This service notifies the creator of the default branch of this automatic branch protection setup by filing an issue in the repository.

Branch Autoprotector 2 Jan 31, 2022
CLI utility to move (or rename) your files to a new location and redirect all of its symbolic links, to the new path

Move Links CLI utility to move (or rename) your files to a new location and redirect all of its symbolic links, to the new path (or name). Usage execu

Ben Mefteh 18 May 22, 2022
A CLI tool to rename files to randomly generated strings.

rng-rename A CLI tool to rename files to randomly generated strings. Why? Suppose you downloaded a few hundred images to use as your desktop wallpaper

null 2 Feb 24, 2022
Tiny Rust CLI to checkout a recent git branch interactively

git-select-branch Tiny Rust CLI to checkout a recent git branch interactively. Installation Homebrew brew tap dnjstrom/git-select-branch brew install

Daniel Ström 5 Oct 11, 2022