关于蓝桥实验楼的Python 新手入门课,Python 新手入门课的一些更正。
Python 新手入门课_Python - 蓝桥云课 (lanqiao.cn)
视频教程
git/github采用token进行认证访问,master改main分支问题_哔哩哔哩_bilibili
关于分支的更正
由于master一词原意为主人,让玻璃心的某些LJ觉得这有歧视嫌疑(黑奴和主人)。
2020年10月1日后,Github会将所有新建的仓库的默认分支从master修改为main,这就导致了一些旧仓库主分支是master,新仓库主分支是main的问题,这在有时候会带来一些麻烦,因此这里提供一种方案将旧仓库的master分支迁移到main分支。
关于新旧分支合并问题请参考Github仓库master分支到main分支迁移指南 - 简书 (jianshu.com)
新手不涉及以上问题,但你要知道目前github的主分支名字交main,不叫master
token认证提交代码演示说明
本次将以我个人的github Demo项目作为演示
https://github.com/hao203/Demo.git
我生成的token(以此为演示),请替换成自己生成的
token: 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
git添加token认证
github在2020年8月13日更新以后,停止了对https用户名及密码的支持,可以添加token认证。
生成token
在github右上角头像单击
settings->developer settings ->personal access tokens-generate new token
记住token值。因为只会显示一次。
使用token的方法一:
git url上添加token
git remote -v
查看remote分支,显示如下
将remote分支url改成(注意,好像目前token前面的用户名可以去掉,即可以直接token值@github.com/**/Demo.git)
https://【用户名username】:token值@github.com/hao203/Demo.git
比如
https://hao203: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@github.com/hao203/Demo.git
可以通过对远程仓库重新设置
git remote rm origin
git remote add origin https://hao203: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@github.com/hao203/Demo.git
或者直接改,不删原先的origin(推荐该法)
git remote set-url origin https://hao203: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@github.com/hao203/Demo.git
然后就ok了
如果push还有报错
fatal: unable to access 'https://github.com********/': OpenSSL SSL_read: Connection was aborted, errno 10053
再执行
git config --global http.sslVerify "false"
使用token方法二:
其实虽然密码不能用,但用户名和token(把token作为密码)的组合是可以使用进行认证并提交的。
当你使用一次,
可以用一个credential.helper cache方法,将其保存下来
git config --global credential.helper cache
下次就不会再让你输账户和密码提交了。
想要解除这个认证
git config --global --unset credential.helper