我们正在将一个Git存储库移动到一个新的服务器。在迁移之后,我们显然可以删除旧的存储库,所以当人们尝试推送或拉入时,他们会得到一个错误,并在wiki上查找新的存储库URL,但有没有可能改为阻止拉入和推送,并在错误消息中显示新的URL?
发布于 2015-04-17 20:08:07
您可以使用“预接收”钩子来完成此操作。您需要在旧存储库的.git/hooks目录中创建一个名为pre-receive的文件。确保它是可执行的(sudo chmod +x pre-receive),并将文件的内容设置为如下所示:
echo;
echo "This is the old master repo.";
echo "The repo has been moved. Please update 'origin' accordingly:";
echo;
echo "git remote set-url origin user@new-server.com:/path/to/new/repo.git"
echo;
# Reject the push:
exit 1;现在,当有人试图推送到旧的repo时,它将返回上述消息并拒绝推送。
https://stackoverflow.com/questions/25524278
复制相似问题