github personal access token

fork了一份unreal源码,想用sourcetree clone到本地,但提示“这是一个无效路径/URL”,点详细,看到报错信息:

命令: git -c diff.mnemonicprefix=false -c core.quotepath=false --no-optional-locks ls-remote https://github.com/wantnon/UnrealEngine-Yang
输出:
错误: remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/wantnon/UnrealEngine-Yang/'

命令: hg identify extensions.hgext.hgsubversion=! https://github.com/wantnon/UnrealEngine-Yang
输出:
错误: abort: HTTP Error 404: Not Found

命令: perl.exe C:\Users\admin\AppData\Local\SourceTree\app-3.4.15\tools\svn.pl info https://github.com/wantnon/UnrealEngine-Yang
输出:
错误: System.ComponentModel.Win32Exception: 系统找不到指定的文件。

gpt回答:

即是说,从报错信息看,这个仓库需要使用personal access token访问才行,并给出了git命令写法:

git -c diff.mnemonicprefix=false -c core.quotepath=false --no-optional-locks ls-remote https://<your-username>:<personal-access-token>@github.com/<your-username>/<repository>.git

所以解法如下:

1,source登录github:

 2,github页面上申请personal access token:

参考:SourceTree Push 代码报错:remote: Support for password authentication was removed on August 13, 2021. - 简书 (jianshu.com)

github页面settings->developer settings,创建一个名为myCommonToken的token:

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(注:此token现已失效)

 

token设置如下:(all repositories+权限全开)

 3,运行命令行:

在sourcetree命令行中运行命令:

git -c diff.mnemonicprefix=false -c core.quotepath=false --no-optional-locks ls-remote https://wantnon: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@github.com/wantnon/UnrealEngine-Yang.git

可见,成功列出了仓库中文件,说明访问成功了。

接下来clone。

切换目录:

clone:

git clone https://wantnon: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@github.com/wantnon/UnrealEngine-Yang.git

clone成功。

然后把clone到本地的仓库添加到sourcetree即可:

 

 

posted on 2023-10-11 01:09  wantnon  阅读(211)  评论(0编辑  收藏  举报

导航