Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save MakowskiHubert/d3485289707b1da0eb8ef0627a5aba31 to your computer and use it in GitHub Desktop.

Select an option

Save MakowskiHubert/d3485289707b1da0eb8ef0627a5aba31 to your computer and use it in GitHub Desktop.

Revisions

  1. @maxmarkus maxmarkus revised this gist Mar 24, 2016. 1 changed file with 2 additions and 9 deletions.
    11 changes: 2 additions & 9 deletions pre-commit-hook-merge-conflicts.sh
    Original file line number Diff line number Diff line change
    @@ -4,16 +4,9 @@

    # Tested on Linux and Mac

    # CONFIG
    # Give options empty values to bypass checks ("OPTIONNAME=")

    # whether to check ig git merge conflicts have been added
    CONFLICTS=1

    # Simple check for merge conflics
    if [[ -n $CONFLICTS ]]; then
    conflicts=`git diff --cached --name-only -G"<<<<<|=====|>>>>>"`
    fi
    conflicts=`git diff --cached --name-only -G"<<<<<|=====|>>>>>"`


    # Something went wrong
    if [[ -n "$conflicts" ]]; then
  2. @maxmarkus maxmarkus created this gist Mar 24, 2016.
    30 changes: 30 additions & 0 deletions pre-commit-hook-merge-conflicts.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    #!/bin/bash

    # Check for merge conflicts

    # Tested on Linux and Mac

    # CONFIG
    # Give options empty values to bypass checks ("OPTIONNAME=")

    # whether to check ig git merge conflicts have been added
    CONFLICTS=1

    # Simple check for merge conflics
    if [[ -n $CONFLICTS ]]; then
    conflicts=`git diff --cached --name-only -G"<<<<<|=====|>>>>>"`
    fi

    # Something went wrong
    if [[ -n "$conflicts" ]]; then
    echo
    echo "Unresolved merge conflicts in these files:"

    for conflict in $conflicts; do
    echo $conflict
    done;

    exit 1;
    fi

    exit 0