Git 免密、免 SSH 进行 push & pull
source link: https://blog.hclonely.com/posts/8585e79a/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Git 免密、免 SSH 进行 push & pull
本文介绍了如何不使用帐号密码,不配置 SSH 对 git 远程仓库进行拉取(pull)和推送(push), 如果你需要经常换电脑或使用公共电脑的话使用此方法比较安全。这里主要介绍 Github, Coding, 码云这三个比较主流的托管平台的配置方法。
Github
- 登录 Github, 点击右上角的头像->
Settings
- 点击
Developer settings
- 点击
Personal access tokens
- 点击
Generate new token
创建一个token
Note
随便填就行,Select scopes
勾选repo
给与 repo 操作权限,然后拉到最下面点击Generate token
即可
- 记住这个 token(我这里加密了,实际上是一串字母数字)
以
https://github.com/user/repo.git
仓库为例,只需要在仓库前面添加x-access-token:**************@
即可,************
替换成上一步的 token
Coding
- 登录 Coding, 点击右上角的头像->
个人设置
- 点击
访问令牌
- 点击
新建令牌
创建一个令牌
令牌描述
随便填就行,选择权限
勾选project:depot
给与仓库操作权限,然后拉到最下面点击创建令牌
即可
- 记住这个用户名和令牌(我这里加密了,实际上是一串字母数字)
以
https://e.coding.net/user/project/repo.git
仓库为例,只需要在仓库前面添加用户名:令牌@
即可,用户名
和令牌
替换成上一步的用户名和令牌
- 登录码云, 点击右上角的头像->
设置
- 点击
私人令牌
- 点击
生成新令牌
创建一个令牌
私人令牌描述
随便填就行,请选择将要生成的私人令牌所拥有的权限
勾选projects
给与仓库操作权限,如果弄需要Pull Requests
那就把下面的pull_requests
也勾选上,然后拉到最下面点击提交
即可
- 记住这个令牌(我这里加密了,实际上是一串字母数字)
以
https://gitee.com/user/repo.git
仓库为例,只需要在仓库前面添加oauth2:**********
即可,**********
替换成上一步的令牌
安全起见,如果你使用公共电脑进行仓库的 push&pull 操作,请在离开时删除你的代码仓库,如果你之后还要用不想删除代码仓库,请使用git remote rm
命令把仓库链接删掉!
v1.4.16
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK