git推送代码Gogs报401错误

1.git push 报错:RPC failed; HTTP 401 curl 22 The requested URL returned error: 401 The remote end hung up

2.原因:用户名和密码输错,webstorm会记住git账号密码(即使是错误的账号和密码),导致验证不通过,没有权限推送

3.解决:

(1)删除原始远程数据源:

git remote rm origin

(2)重新添加远程数据源,即在http后面,git前面加上用户名@(shenyf@):

git remote add origin http://shenyf@git.intra.xxx-view.cn:3000/xxx/xxx_xx.git

git推送代码Gogs报401错误

(3)查看此时远程数据源,已经添加成功:

git remote -v

(4)此时再执行push操作,会重新提示输入用户名和密码,输入正确用户名和密码即可,若输错,仍然不提示,依旧显示推送失败