Git:设置只读远程? [英] Git: Set up a fetch-only remote?

查看:480
本文介绍了Git:设置只读远程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在一个配置了远程的Git仓库中运行 git remote -v 时,我发现每个远程仓库都有抓取和推送规格:

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

对于指向对等开发者的遥控器无需推送,Git将拒绝推入非裸仓库。有没有什么办法可以将这些遥控器配置为无提取地址功能?

认为你可以删除推送网址,你只能覆盖它不是拉URL。所以我认为最接近的是这样的:

  $ git remote set-url --push origin no-推
$ git push
致命:'不推送'似乎不是git存储库
致命:远程端意外挂起

您将推送网址设置为不推送,只要您不' t在你的工作目录中有一个相同名字的文件夹,git将无法找到。你基本上是强迫git使用一个不存在的位置。


When I run git remote -v in one of my Git repositories that has a remote(s) configured, I see that each remote has both fetch and push specs:

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

For remotes that point to peer developers there's no need to push, and Git will refuse to push to a non-bare repository anyway. Is there any way to configure these remotes as "fetch-only" with no push address or capabilities?

解决方案

I don't think you can remove the push URL, you can only override it to be something other than the pull URL. So I think the closest you'll get is something like this:

$ 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

You are setting the push URL to no-pushing, which, as long as you don't have a folder of the same name in your working directory, git will not be able to locate. You are essentially forcing git to use a location that does not exist.

这篇关于Git:设置只读远程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆