我在.git / hooks / pre-commit
中有这个预提交钩子#!/bin/bash
for file in `git diff --name-only`
do
if [[ $file =~ /pom\.xml$ ]]; then
exec < /dev/tty
read -p "Committing $file is often a mistake; are you sure you want to do that? (Y/[N]): " ans
exec <&-
if [[ $ans =~ ^[Yy]$ ]]; then
echo proceeding rashly with commit...
else
echo aborting commit, O prudent one.
exit 1
fi
fi
done
当我使用github for mac(GUI客户端)提交时,它会显示以下错误:
.git/hooks/pre-commit: line 5: /dev/tty: Device not configured
aborting commit, O prudent one.
(1)
它适用于命令行。但我希望让GUI客户端工作。有任何想法吗?谢谢!
答案 0 :(得分:0)
您的gui客户端在挂钩期间不提供tty或任何其他方式从用户获取输入。所以这是不可能的。我看到了这个问题的两个解决方案:
git reset HEAD^
一样简单。