gpt4 book ai didi

Git:设置一个只获取的远程?

转载 作者:IT王子 更新时间:2023-10-29 01:22:32 25 4
gpt4 key购买 nike

当我在我的一个配置了远程的 Git 存储库中运行 git remote -v 时,我看到每个远程都有获取和推送规范:

$ git remote -v
<remote-name> ssh://host/path/to/repo (fetch)
<remote-name> ssh://host/path/to/repo (push)

对于指向对等开发人员的 Remote ,无需推送,Git 无论如何都会拒绝推送到非裸存储库。有什么方法可以将这些 Remote 配置为“仅获取”而没有推送地址或功能?

最佳答案

我不认为您可以删除推送 URL,您只能覆盖它是 pull URL 以外的内容。所以我认为最接近的是这样的:

$ git remote set-url --push origin no-pushing
$ git push
fatal: 'no-pushing' does not appear to be a git repository
fatal: The remote end hung up unexpectedly

您将推送 URL 设置为 no-pushing,只要您的工作目录中没有同名文件夹,git 就无法定位。您实际上是在强制 git 使用不存在的位置。

关于Git:设置一个只获取的远程?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7556155/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com