Giter VIP home page Giter VIP logo

main-branch-switch's Introduction

Scripts for switching Github repos to use a "main" branch as the default. Original source at https://github.com/dsyer/main-branch-switch

Pre-requisites: you need the Hub CLI to interact with Github, and you need JQ for parsing and mangling JSON. Make sure all three of the scripts in this repo are on your PATH. You may need to authenticate with Github via Hub before you start (or it might prompt you the first time it needs it).

$ git clone https://github.com/heroku/main-branch-switch && cd $_
$ export PATH=`pwd`:$PATH

To create a "main" branch and retarget all the pull requests for a repo at Heroku:

$ main_branch.sh --repo <myrepo>

You can switch orgs --org <myorg> and you can target a specific repository with --repo <myrepo>.

The retarget.sh script can be used on its own to re-target pull requests (it is used by the main_branch.sh script):

$ retarget.sh --org <myorg> <myrepo> main 1234

If your repository uses branch protections, the branch_protect.sh script can be used to copy the settings from the base branch to the new branch. (it is used by the main_branch.sh script by default):

$ branch_protect.sh --org <myorg> <myrepo> main 

The default org is "heroku", and the default pull request is all of them (the open ones).

What to do in your Fork

If you have a fork of a project that has changed its default branch, you probably want to update the remote:

$ git fetch origin --prune
$ git checkout main
$ git branch -d master
$ git remote set-head origin main

If you normally work with origin as the upstream then you are good to go. If you want your remote fork to be the upstream then you need to also do this, or something equivalent:

$ git push <myorg> main --set-upstream

main-branch-switch's People

Contributors

apghero avatar

Stargazers

 avatar

Watchers

 avatar  avatar  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.