Skip to content

Instantly share code, notes, and snippets.

@mrexodia
Last active December 5, 2024 12:01
Show Gist options
  • Select an option

  • Save mrexodia/5a23ab69639a6abc343ac0415958947a to your computer and use it in GitHub Desktop.

Select an option

Save mrexodia/5a23ab69639a6abc343ac0415958947a to your computer and use it in GitHub Desktop.

Revisions

  1. mrexodia revised this gist Dec 5, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git-finished.sh
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@ else
    exit 1
    fi

    if "$MAIN" == "$FEATURE"; then
    if [ "$MAIN" = "$FEATURE" ]; then
    echo "Already on $MAIN" >&2
    exit 0
    fi
  2. mrexodia created this gist Dec 5, 2024.
    21 changes: 21 additions & 0 deletions git-finished.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    #!/bin/bash
    FEATURE=$(git branch --show-current)

    if git show-ref --quiet refs/remotes/origin/main; then
    MAIN=main
    elif git show-ref --quiet refs/remotes/origin/master; then
    MAIN=master
    else
    echo "No main branch found" >&2
    exit 1
    fi

    if "$MAIN" == "$FEATURE"; then
    echo "Already on $MAIN" >&2
    exit 0
    fi

    git fetch origin --prune
    git checkout $MAIN
    git pull
    git branch --delete $FEATURE