Created
March 24, 2016 13:26
-
-
Save maxmarkus/8a81edd58dd65a45731f to your computer and use it in GitHub Desktop.
Git pre-commit hook to prevent checking in non-resolved merge conflicts.
This file contains 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 |
It seems ok.
pre-commit has an official hook for this.
Just add this to your pre-commit-config.yaml
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-merge-conflict
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Awesome! Thank you!