Linux代码维护
作者QQ:67065435 QQ群:669756510
本站内容全部为作者原创,转载请注明出处!
Git记住密码
- 永久记住密码
# 密码会被明文保存到Linux:~/.git-credentials # 密码会被明文保存到Windows:C:/User/【用户】/.git-credentials git config --global credential.helper store
Github翻墙
启用代理
# 假设使用clash配置了http://127.0.0.1:7890作为VPN地址 # 注意:启用代理但代理服务未开启或运行异常会导致无法访问github!!! git config --global http.proxy http://127.0.0.1:7890 git config --global https.proxy http://127.0.0.1:7890取消代理
git config --global --unset http.proxy git config --global --unset https.proxy
Github双重身份验证
修改远程仓库地址及协议
git remote set-url origin git@github.com:【Github账号邮箱】/【仓库名称】.git git remote set-url origin https://github.com/【Github账号邮箱】/【仓库名称】.git以https协议访问远程仓库
# 打开github官网 https://github.com/ # 依次点击以下路径 右上角头像→Settings→Developer settings →Personal access tokens→Tokens (classic) →Generate new token (classic) →输入标题(任意写) →选择有效期(No expiration永久有效) →Select scopes(用到的能力都选上) →Generate token # 新建后保存(token窗口关闭后将无法再次查看一定要妥善保存再关闭) # 保存到本地linux系统验证文件中(多家代码仓库存多行即可) vim ~/.git-credentials https://【Github账号邮箱】:【token】@github.com ESC :wq # 接下来就可以正常推拉代码了以ssh协议访问远程仓库 ```
本地Linux系统生成密钥文件
ssh-keygen -t rsa -b 4096 -C "Github账号邮箱"
获取公钥内容
cat ~/.ssh/id_rsa.pub
打开github官网
依次点击以下路径
右上角头像→Settings→ →SSH and GPG keys →New SSH key →输入标题(任意写) →输入获取的公钥内容 →Add SSH key
接下来就可以正常推拉代码了
```