一、问题描述
在 Sourcetree 上使用 git push 代码的时候报错:The requested URL returned error: 403
,表示没有权限来 push 相关代码
二、问题解决
如果你之前在 GitHub 配置过 Personal access tokens,也就是 个人访问令牌,那么出现该问题的原因,可能是 token 过期失效,或者是没有配置 token 导致身份验证失败。
事实上,这个问题困扰我许久,网上资料很少,仅有的一些资料也没有解决我的问题。我是在邮箱里看到一封名为 [GitHub] Your personal access token has expired
的邮件,才突然想到有可能是 token 的问题。
为什么会涉及到 token,简单讲一下背景,主要是因为 GitHub 于 2020 年 12 月 15 日在官方博客发布的文章: Token authentication requirements for Git operations。
In July 2020, we announced our intent to require the use of token-based authentication (for example, a personal access, OAuth, or GitHub App installation token) for all authenticated Git operations. Begi