git - 如何检查对远程 Git 存储库 ("can I push?"的写入权限)

标签 git github git-remote ls-remote

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

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

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

最佳答案

如果 git 仓库在 github 中,打开仓库中的任意文件,然后单击“编辑”, github 将显示如下内容:

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 - 如何检查对远程 Git 存储库 ("can I push?"的写入权限),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22811045/

相关文章:

linux - 如何更改 gitolite 上的存储库位置?

git - 更改 Git 远程 'push to' 默认值

git - 在同一个分支上工作,如何在不丢失更改的情况下进行 pull ?

ruby-on-rails - [尝试部署] : You must use Bundler 2 or greater with this lockfile

git - 如何获得 `git diff origin/master` 的相反方向

ruby-on-rails - 杰基尔 3.7.3 |错误 : No source of timezone data could be found

git - 防止git推送到错误的远程

Git:修改工作目录时如何检查本地分支是否领先于远程分支?

github:将提交添加到现有的 pull 请求

git - 如何通过 github 中的计数减少提交消息?