美文网首页
Git专栏5:SourceTree拉取pull代码和推送push

Git专栏5:SourceTree拉取pull代码和推送push

作者: 物非0人非 | 来源:发表于2022-05-23 10:47 被阅读0次

前言:

SourceTree拉取pull代码 和 推送push代码报错问题

问题1: 用github来管理自己的仓库。推送代码到github上面的时候,却一直报错!

截图和报错信息如下

remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.
remote: Please see https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information.
fatal: Authentication failed for 'https://github.com/xiaYingwudi/cocoPodsXYTestProject.git/'
Completed with errors, see above

问题分析解决:github管理代码仓库规则变了,需要用到token访问令牌

远程:对密码身份验证的支持已于 2021 年 8 月 13 日删除。请改用个人访问令牌。
远程:有关详细信息,请参阅 https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/。
fatal: Authentication failed for 'https://github.com/zhousujuan/full-stack-front-end-learning.git/'
致命:"https://github.com/xiaYingwudi/cocoPodsXYTestProject.git/"的身份验证失败

如何生成token
1,打开Github,在个人设置页面,找到【Setting】,然后打开找到【Devloper Settting】,如下图。


image.png

然后,选择个人访问令牌【Personal access tokens】,然后选中生成令牌【Generate new token】。


image.png

在上个步骤中,选择要授予此令牌token的范围或权限。

要使用token从命令行访问仓库,请选择repo
要使用token从命令行删除仓库,请选择delete_repo
其他根据需要进行勾选
然后,点击【Generate token】生成令牌。


image.png
image.png

成token后,记得把你的token保存下来,以便进行后面的操作。把token直接添加远程仓库链接中,这样就可以避免同一个仓库每次提交代码都要输入token了。

git remote set-url origin https://<your_token>@github.com/<USERNAME>/<REPO>.git
  • <your_token>:换成你自己得到的token
  • <USERNAME>:是你自己github的用户名
  • <REPO>:是你的仓库名称

下面是一个实例:

git remote set-url origin https://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@github.com/shliang0603/Yolov4_DeepSocial.git/

相关文章

网友评论

      本文标题:Git专栏5:SourceTree拉取pull代码和推送push

      本文链接:https://www.haomeiwen.com/subject/pilcprtx.html