git gitlab - 使用 access_token 推送到存储库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42074414/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
gitlab - Push to a repository using access_token
提问by Simon Bruneaud
I implemented the oauth2 web flow in order to get access_token from users of my app. With the access_token, I would like to do the following actions:
我实现了 oauth2 网络流程,以便从我的应用程序的用户那里获取 access_token。使用 access_token,我想做以下操作:
- Get user informations
- Create a repo for this user
- Push code to this repo (using git push )
- 获取用户信息
- 为这个用户创建一个仓库
- 将代码推送到这个仓库(使用 git push )
I already successfully get the user information(1) and create a repo(2)
我已经成功获取了用户信息(1)并创建了一个repo(2)
The problem is I can't push code (3), I got "Unauthorized" error.
问题是我无法推送代码 (3),出现“未经授权”错误。
The command I run:
我运行的命令:
git remote add origin https://gitlab-ci-token<mytoken>@gitlab.com/myuser/myrepo.git
git push origin master
回答by Dave Reikher
You should do
你应该做
git remote add origin https://oauth2:<mytoken>@gitlab.com/myuser/myrepo.git
回答by Akif
It is also possible to push directly without adding a new remote repository:
也可以直接推送而不添加新的远程存储库:
git push https://gitlab-ci-token:<access_token>@gitlab.com/myuser/myrepo.git <branch_name>
This could be especially handy if you would like pull & push to different repositories.
如果您想拉和推到不同的存储库,这可能特别方便。
回答by Nicolas Pepinster
Push using gitlab-ci-token
is not currently supported by Gitlab. There is an open feature request.
gitlab-ci-token
Gitlab 目前不支持推送使用。有一个开放的功能请求。