如何通过命令行界面邀请人们加入私有GitHub存储库? [英] How to invite people to private GitHub repo through command line interface?

查看:57
本文介绍了如何通过命令行界面邀请人们加入私有GitHub存储库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常,访问" https://github后,必须单击链接"邀请团队或人".com///settings/access".但是,我希望通过命令行界面进行此操作,因为我必须邀请很多人.是否可以?

解决方案

您可以使用GitHub API来此处:

  curl -H授权:令牌YOUR_TOKEN";" https://api.github.com/repos/YOUR_USER_NAME/YOUR_REPO/collaborators/COLLABORATOR_USER_NAME"-X PUT -d'{'permission':'admin'}' 

许可级别为以下之一:

  • pull -可以拉出但不能推送或管理此存储库.

  • push -可以拉动但不能管理该存储库.
  • admin -可以拉,推和管理该存储库.
  • 维护 -建议用于需要管理存储库而又不能访问敏感或破坏性操作的项目经理.
  • triage -适用于需要主动管理问题并在没有写访问权限的情况下提出请求的贡献者.

(默认为"push")

考虑到GitHub CLI gh 现在是1.0 ,这可能是一个很好的功能(添加了 gh repo invite )>

同时,您可以使用 gh pi 来使用 -f 进行类似的自动身份验证的API调用,以添加 POST 字段.

  gh api repos/YOUR_USER_NAME/YOUR_REPO/collaborators/COLLABORATOR_USER_NAME""-f'{'permission':'admin'}' 

Usually one must click link "Invite teams or people" after accessing "https://github.com///settings/access" in a web browser. But, I wish to do this through a command line interface, because I must invite many persons. Is it possible?

解决方案

You could use the GitHub API in order to add a collaborator

PUT /repos/:owner/:repo/collaborators/:username

See for instance here:

curl -H "Authorization: token YOUR_TOKEN" "https://api.github.com/repos/YOUR_USER_NAME/YOUR_REPO/collaborators/COLLABORATOR_USER_NAME" -X PUT -d '{"permission":"admin"}'

With permission level being one of:

  • pull - can pull, but not push to or administer this repository.

  • push - can pull and push, but not administer this repository.
  • admin - can pull, push and administer this repository.
  • maintain - Recommended for project managers who need to manage the repository without access to sensitive or destructive actions.
  • triage - Recommended for contributors who need to proactively manage issues and pull requests without write access.

(default is "push")

Update Sept. 2020, considering GitHub CLI gh is now 1.0, it could be a good feature to add (a kind of gh repo invite)

In the meantime, you can use gh pi to make a similar API call, automatically authenticated, with -f to add POST fields.

gh api repos/YOUR_USER_NAME/YOUR_REPO/collaborators/COLLABORATOR_USER_NAME" -f '{"permission":"admin"}'

这篇关于如何通过命令行界面邀请人们加入私有GitHub存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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