如何检查对远程Git存储库的写访问权限(“我可以推送吗?") [英] How can I check write access to a remote Git repository ("can I push?")

查看:1285
本文介绍了如何检查对远程Git存储库的写访问权限(“我可以推送吗?")的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个(有点受限制的)Git客户端.要设置存储库,请输入远程仓库的URL.我想检查用户是否对该存储库具有读写访问权限.如果没有,我会显示一个身份验证对话框.

I am building a (somewhat limited) Git client. To set up a repository, you enter the URL to the remote repo. I want to check whether the user has read+write access to that repository. If not, I present an authentication dialog.

我用git ls-remote <url>检查读取"访问权限.

是否有类似的方法可以检查'写'访问权限,而无需先克隆存储库? (我知道我可以先git clone <url>然后git push --dry-run)

Is there an analogous way to check 'write' access, without cloning the repo first? (I know I could git clone <url> and then git push --dry-run)

推荐答案

如果git存储库位于github中,请打开该存储库中的任何文件,然后单击编辑", github将显示如下内容:

If the git repo is in github, open any file in the repo, then click 'edit', github will show something like this:

您正在编辑一个没有写权限的项目中的文件.我们为此项目创建了一个分支,以供您提交建议的更改 到.提交对此文件的更改会将其写入以下位置的新分支 您的叉子,因此您可以发送拉取请求.在此处输入代码

You’re editing a file in a project you don’t have write access to. We’ve created a fork of this project for you to commit your proposed changes to. Submitting a change to this file will write it to a new branch in your fork, so you can send a pull request.enter code here

这篇关于如何检查对远程Git存储库的写访问权限(“我可以推送吗?")的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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