Github 使用token验证提交代码的两种方式

Github 使用token验证提交代码的两种方式

第一步,当然是生成token

生成token的方法,不在详细介绍 官方步骤在此

注:生成的token只展现一次,注意保存!!!!!!!!


image

使用token

第一种方式,输入用户名和token

进行git命令行提交的时候,会让你输入UsernamePassword
例如: 我的git 地址是https://github.com/WMSmile/wechat-components.git

git push
Username for 'https://github.com': WMSmile
Password for 'https://WMSmile@github.com': 你的token

提交输入Username为:WMSmile
提交输入Password为:第一步申请的token

第二种方式,直接更改.git/config文件 (不推荐)

注:不建议使用这种方式!不建议使用这种方式!不建议使用这种方式!因为这种方式压缩给别人之后,会泄露自己的token的风险。

.git/是隐藏文件。需要显示出来,mac 快捷键是control + cmd + .

[remote "origin"]
    url = https://github.com/WMSmile/wechat-components.git
    fetch = +refs/heads/*:refs/remotes/origin/*

修改remote 中的url 为

url = https://【你的token】@github.com/WMSmile/wechat-components.git

eg: token为 qwer12345678

url = https://qwer12345678@github.com/WMSmile/wechat-components.git
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容