我正在尝试将我的个人服务器作为主要的git远程仓库,并自动将其镜像到github。我找到了这篇文章,它使用一个
我的方法与众不同,我想避免在每个存储库上创建和保护部署密钥,然后对其进行配置。
我的
post-receive
脚本来实现大部分功能,该脚本执行git push --mirror
(本质上是如此)。我的方法与众不同,我想避免在每个存储库上创建和保护部署密钥,然后对其进行配置。
我的
post-receive
脚本正确地处理了下面大部分变体的注释标记,除了如上述博客文章中的完整的nohup + stdio重定向 + 后台处理方式,认证停止工作。GITHUB_USERNAME=focusaurus
BARE_PATH=$(pwd -P)
REPO_NAME=$(basename "${BARE_PATH}")
REPO_URL="ssh://git@github.com/${GITHUB_USERNAME}/${REPO_NAME}"
echo "About to mirror to ${REPO_URL}"
#hmm, this works
#git push --mirror "${REPO_URL}"
#this works, too
#nohup git push --mirror "${REPO_URL}"
#and this also works OK
nohup git push --mirror "${REPO_URL}" &
#but this fails with
#Permission denied (publickey).
#fatal: The remote end hung up unexpectedly
#Somehow ssh agent forwarding must get screwed up? Help me, Internet.
#nohup git push --mirror "${REPO_URL}" &>>/tmp/mirror_to_github.log &
#this is the one used in the blog post above but it also fails
# nohup git push --mirror "${REPO_URL}" &>/dev/null &
我有SSH代理转发,我相信这就是工作版本的原因。那么我的问题是,为什么最后两个变体会出现身份验证错误?
nohup git push --mirror "${REPO_URL}" >/dev/null 2>&1 &
吗? - Eamonn O'Brien-Straingit push -v
似乎没有增加任何详细信息,所以我很难有效地进行故障排除。 - Peter Lyons