更改git提交的协议

现象: push代码时gitlog出现 remote: HTTP Basic: Access denied

原因: git仓库设置了权限, You won’t be able to pull or push project code via HTTPS until you create a personal access token on your account(大白话: 无法使用HTTPS协议)

解决方案: 修改远程仓库地址为ssh协议的地址

具体操作如下:

1
2
3
4
5
6
7
8
# 两种方法

# 1 修改
$ git remote set-url origin [url]

# 2 先删后加
$ git remote rm origin
$ git remote add origin [url]