I created the following pre-push script in my local repository .git/hooks/
to disallow pushing files with unresolved git conflicts to server:
#!/bin/bash
top_dir=$(git rev-parse --show-toplevel)
conflicts=$(grep -r -n -s --include=\*.{pm,pl,mc,mi,js,css} "<<<<<<< HEAD" "$top_dir")
if [ "$conflicts" = "" ]; then
exit 0
else
printf "Unresolved git conflict found, commit rejected.\n\n"
echo "$conflicts"
exit 1
fi
It works. But how can we reject all the commits with unresolved conflicts on server side pre-receive
? Here I know top_dir
- the dir, where to grep. But on server there are no saved files saved. I need to grep among the files that the client sends me.
How to do it?