»
(008) CubeIDE Implementation of USB Peripherals*
(018) C99 pointer*
(019) C99 With only value assignment*
(022) POSIX pthread multi-threads mutex*
(023) POSIX pthread multi-threads programming*
(027) C99 time and wait*
(028) High-precision calculation with GMP*
(029) Web Service Lib*
(030) International Components for Unicode (ICU)*
(031) Performance of C is higher than C++, because...*
🍓(013) Ban Git force push
Git禁止用户强制推送的方法:
cd /path/to/repo.git/hooks
touch pre-receive
chmod +x pre-receive
#!/bin/bash
# 读取标准输入,获取引用更新信息
while read old_ref new_ref ref_name; do
echo "Received push:"
echo "Old ref: $old_ref"
echo "New ref: $new_ref"
echo "Ref name: $ref_name"
# 示例:禁止强制推送
if [ "$old_ref" = "0000000000000000000000000000000000000000" ]; then
echo "ERROR: Force push is not allowed."
exit 1
fi
# 示例:禁止删除分支
if [ "$new_ref" = "0000000000000000000000000000000000000000" ]; then
echo "ERROR: Deleting branches is not allowed."
exit 1
fi
done
# 如果脚本正常退出(返回 0),则允许推送
exit 0
来自:DeepSeek