Skip to content

Instantly share code, notes, and snippets.

@colantuomo
Last active June 2, 2021 13:45
Show Gist options
  • Save colantuomo/e948aca773be8b289045a1de9f23dde2 to your computer and use it in GitHub Desktop.
Save colantuomo/e948aca773be8b289045a1de9f23dde2 to your computer and use it in GitHub Desktop.

Revisions

  1. colantuomo revised this gist Jun 2, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion useful-scripts.md
    Original file line number Diff line number Diff line change
    @@ -15,7 +15,6 @@ function smart_checkout() {
    fi
    done
    }
    alias push_origin='git push -u origin "$(get_branch)"'
    ```

    #### Get the current branch:
    @@ -25,4 +24,5 @@ function get_branch() {
    || echo "default_value"
    }

    alias push_origin='git push -u origin "$(get_branch)"'
    alias clear_branches='git branch | grep -v "master" | xargs git branch -D'
  2. colantuomo revised this gist May 27, 2021. 1 changed file with 4 additions and 3 deletions.
    7 changes: 4 additions & 3 deletions useful-scripts.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,7 @@
    ## A List of usefull bash scripts for MacOS and Linux

    A smart way to checkout from branches:
    ## A List of useful bash scripts for MacOS and Linux

    #### A smart way to checkout from branches:
    ```bash
    function smart_checkout() {
    git branch
    @@ -17,7 +18,7 @@ function smart_checkout() {
    alias push_origin='git push -u origin "$(get_branch)"'
    ```

    Get the current branch:
    #### Get the current branch:
    ```bash
    function get_branch() {
    git branch --no-color | grep -E '^\*' | awk '{print $2}' \
  3. colantuomo revised this gist May 27, 2021. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions useful-scripts.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    ## A List of usefull bash scripts for MacOS and Linux

    A smart way to checkout from branches:
    ```bash
    function smart_checkout() {
  4. colantuomo renamed this gist May 27, 2021. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  5. colantuomo renamed this gist May 27, 2021. 1 changed file with 7 additions and 3 deletions.
    10 changes: 7 additions & 3 deletions gistfile1.sh → gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@

    A smart way to checkout from branches:
    ```bash
    function smart_checkout() {
    git branch
    echo "Type part of the branch you want to move?"
    @@ -11,11 +12,14 @@ function smart_checkout() {
    fi
    done
    }
    alias push_origin='git push -u origin "$(get_branch)"'
    ```

    Get the current branch:
    ```bash
    function get_branch() {
    git branch --no-color | grep -E '^\*' | awk '{print $2}' \
    || echo "default_value"
    }

    alias push_origin='git push -u origin "$(get_branch)"'
    alias clear_branches='git branch | grep -v "master" | xargs git branch -D'
    alias clear_branches='git branch | grep -v "master" | xargs git branch -D'
  6. colantuomo renamed this gist May 27, 2021. 1 changed file with 9 additions and 3 deletions.
    12 changes: 9 additions & 3 deletions gistfile1.txt → gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,4 @@
    A easy way to checkout from branchs
    ```bash

    function smart_checkout() {
    git branch
    echo "Type part of the branch you want to move?"
    @@ -12,4 +11,11 @@ function smart_checkout() {
    fi
    done
    }
    ```

    function get_branch() {
    git branch --no-color | grep -E '^\*' | awk '{print $2}' \
    || echo "default_value"
    }

    alias push_origin='git push -u origin "$(get_branch)"'
    alias clear_branches='git branch | grep -v "master" | xargs git branch -D'
  7. colantuomo created this gist May 27, 2021.
    15 changes: 15 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    A easy way to checkout from branchs
    ```bash
    function smart_checkout() {
    git branch
    echo "Type part of the branch you want to move?"
    read word
    for branch in $(git branch);
    do
    if [[ $branch == *$word* ]]; then
    git checkout $branch
    break;
    fi
    done
    }
    ```