Forked from maxmarkus/pre-commit-hook-merge-conflicts.sh
Created
June 10, 2022 14:53
-
-
Save MakowskiHubert/d3485289707b1da0eb8ef0627a5aba31 to your computer and use it in GitHub Desktop.
Git pre-commit hook to prevent checking in non-resolved merge conflicts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Check for merge conflicts | |
| # Tested on Linux and Mac | |
| # Simple check for merge conflics | |
| conflicts=`git diff --cached --name-only -G"<<<<<|=====|>>>>>"` | |
| # 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment