我想预先接收挂钩可能会有所帮助 我想
#!/bin/sh
read old_sha1 new_sha1 refname
git diff $old_sha1..$new_sha1 may
帮助找出冲突标记
但如何使用正则表达式或其他来判断此提交中是否存在未解决的冲突?
冲突如下:
<<<<<<< HEAD
Conflict resolution is hard;
let's go shopping.
=======
Git makes conflict resolution easy.
>>>>>>> d7785deagea4342532g2q632y321632g23h23
答案 0 :(得分:9)
#!/bin/bash
read old_sha new_sha refname
if git diff "$old_sha" "$new_sha" | grep -qE '^[+]?(<<<<<|>>>>>)'; then
echo "Saw a conflict marker in $(basename "$refname")."
exit 1
fi