Skip to content

Instantly share code, notes, and snippets.

@blimmer
Last active June 17, 2020 20:20
Show Gist options
  • Save blimmer/a7bf33cad9262f01a37be3aba35d881b to your computer and use it in GitHub Desktop.
Save blimmer/a7bf33cad9262f01a37be3aba35d881b to your computer and use it in GitHub Desktop.

Revisions

  1. blimmer revised this gist Jun 17, 2020. 1 changed file with 1 addition and 3 deletions.
    4 changes: 1 addition & 3 deletions rename-master-to-main.sh
    Original file line number Diff line number Diff line change
    @@ -11,6 +11,4 @@ git fetch
    git checkout main
    git pull origin main

    # this might fail if the `master` branch has already been deleted
    set +e
    git branch -D master
    delete_branch=$(git branch -D master) || true
  2. blimmer revised this gist Jun 17, 2020. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion rename-master-to-main.sh
    Original file line number Diff line number Diff line change
    @@ -10,4 +10,7 @@ fi
    git fetch
    git checkout main
    git pull origin main
    git branch -D master || true

    # this might fail if the `master` branch has already been deleted
    set +e
    git branch -D master
  3. blimmer revised this gist Jun 17, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion rename-master-to-main.sh
    Original file line number Diff line number Diff line change
    @@ -10,4 +10,4 @@ fi
    git fetch
    git checkout main
    git pull origin main
    git branch -D master
    git branch -D master || true
  4. blimmer revised this gist Jun 17, 2020. 1 changed file with 3 additions and 5 deletions.
    8 changes: 3 additions & 5 deletions rename-master-to-main.sh
    Original file line number Diff line number Diff line change
    @@ -7,9 +7,7 @@ if ! git diff-index --quiet HEAD --; then
    exit 1
    fi

    git checkout master
    git branch -m master main
    git fetch
    git branch --unset-upstream
    git branch -u origin/main
    git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/main
    git checkout main
    git pull origin main
    git branch -D master
  5. blimmer created this gist Jun 17, 2020.
    15 changes: 15 additions & 0 deletions rename-master-to-main.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    #! /bin/bash

    set -e

    if ! git diff-index --quiet HEAD --; then
    echo "ERROR: you have uncommited changes. Please stash or commit before running this script."
    exit 1
    fi

    git checkout master
    git branch -m master main
    git fetch
    git branch --unset-upstream
    git branch -u origin/main
    git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/main