Skip to content

Instantly share code, notes, and snippets.

@mijdavis2
Forked from jcromartie/pre-commit
Last active June 2, 2021 21:18
Show Gist options
  • Select an option

  • Save mijdavis2/09b6ff4e082faa3e3416d3e663084dd7 to your computer and use it in GitHub Desktop.

Select an option

Save mijdavis2/09b6ff4e082faa3e3416d3e663084dd7 to your computer and use it in GitHub Desktop.

Revisions

  1. mijdavis2 revised this gist Jun 2, 2021. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions pre-commit
    Original file line number Diff line number Diff line change
    @@ -8,10 +8,12 @@
    # the output of rev-list in the following test will be empty if there
    # are no commits in master that aren't in the current branch

    git fetch

    if [ ! -z "$(git rev-list ..master)" ]
    then
    echo "abandoning commit"
    echo "please merge from master and try again"
    echo " git merge master"
    echo "please rebase from master and try again"
    echo " git fetch; git rebase origin/master"
    exit 1
    fi
  2. @jcromartie jcromartie revised this gist May 25, 2011. 1 changed file with 4 additions and 3 deletions.
    7 changes: 4 additions & 3 deletions pre-commit
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    #!/bin/sh
    #!/usr/bin/env bash

    # hook to enforce that current branch is up-to-date with latest
    # changes from master before committing
    @@ -8,9 +8,10 @@
    # the output of rev-list in the following test will be empty if there
    # are no commits in master that aren't in the current branch

    if [ ! -z $(git rev-list ..master) ]
    if [ ! -z "$(git rev-list ..master)" ]
    then
    echo "abandoning commit... it looks like this branch is out of date"
    echo "abandoning commit"
    echo "please merge from master and try again"
    echo " git merge master"
    exit 1
    fi
  3. @jcromartie jcromartie revised this gist May 25, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion pre-commit
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@

    if [ ! -z $(git rev-list ..master) ]
    then
    echo "abandoning commit"
    echo "abandoning commit... it looks like this branch is out of date"
    echo "please merge from master and try again"
    exit 1
    fi
  4. @jcromartie jcromartie revised this gist May 25, 2011. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion pre-commit
    Original file line number Diff line number Diff line change
    @@ -12,6 +12,5 @@ if [ ! -z $(git rev-list ..master) ]
    then
    echo "abandoning commit"
    echo "please merge from master and try again"
    echo " git merge master"
    exit 1
    fi
  5. @jcromartie jcromartie created this gist May 25, 2011.
    17 changes: 17 additions & 0 deletions pre-commit
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    #!/bin/sh

    # hook to enforce that current branch is up-to-date with latest
    # changes from master before committing

    # put me in .git/hooks and make me executable

    # the output of rev-list in the following test will be empty if there
    # are no commits in master that aren't in the current branch

    if [ ! -z $(git rev-list ..master) ]
    then
    echo "abandoning commit"
    echo "please merge from master and try again"
    echo " git merge master"
    exit 1
    fi