Skip to content

Instantly share code, notes, and snippets.

@Shubhamhirau18
Forked from benfrain/post-receive.sh
Created April 11, 2021 17:26
Show Gist options
  • Save Shubhamhirau18/8cc6deaab829c8fd0afc960574d8f660 to your computer and use it in GitHub Desktop.
Save Shubhamhirau18/8cc6deaab829c8fd0afc960574d8f660 to your computer and use it in GitHub Desktop.

Revisions

  1. @benfrain benfrain revised this gist Oct 9, 2013. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions post-receive.sh
    Original file line number Diff line number Diff line change
    @@ -5,12 +5,12 @@ do
    branch=`echo $ref | cut -d/ -f3`

    if [ "master" == "$branch" ]; then
    git --work-tree=/path/under/root/dir/live-site/ checkout -f $branch
    git --work-tree=./path/under/root/dir/live-site/ checkout -f $branch
    echo 'Changes pushed live.'
    fi

    if [ "dev" == "$branch" ]; then
    git --work-tree=/path/under/root/dir/dev-site/ checkout -f $branch
    git --work-tree=./path/under/root/dir/dev-site/ checkout -f $branch
    echo 'Changes pushed to dev.'
    fi
    done
  2. @benfrain benfrain revised this gist Oct 9, 2013. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion post-receive.sh
    Original file line number Diff line number Diff line change
    @@ -13,4 +13,6 @@ do
    git --work-tree=/path/under/root/dir/dev-site/ checkout -f $branch
    echo 'Changes pushed to dev.'
    fi
    done
    done

    # Taken from: http://blog.ekynoxe.com/2011/10/22/git-post-receive-for-multiple-remote-branches-and-work-trees/
  3. @benfrain benfrain created this gist Oct 9, 2013.
    16 changes: 16 additions & 0 deletions post-receive.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    #!/bin/bash

    while read oldrev newrev ref
    do
    branch=`echo $ref | cut -d/ -f3`

    if [ "master" == "$branch" ]; then
    git --work-tree=/path/under/root/dir/live-site/ checkout -f $branch
    echo 'Changes pushed live.'
    fi

    if [ "dev" == "$branch" ]; then
    git --work-tree=/path/under/root/dir/dev-site/ checkout -f $branch
    echo 'Changes pushed to dev.'
    fi
    done