将代码托管到bithub上的时候,在gitbash中执行命令git push origin master报错
Permission to tony-green/coolweather.git denied to xxxx(你的github用户名)
两天了,试过ssh,删除windows凭借,在config的url的github前加入用户名:密码@
网上的办法都不行,最后自己摸索着解决了这个问题
解决办法
从git clone https://github.com/tony-green/coolweather.git克隆远程版本库到本地之后
从coolweather目录复制全部文件到上级目录,并删除coolweather后
重头戏来了
打开.git文件下的config
将[remote "origin"]
url = https://github.com/tony-green/coolweather.git
改为
url = https://github.com/你自己的用户名/coolweather.git
之后执行git push origin master命令,如果有error;
强制push本地仓库到远程 (这种情况不会进行merge, 强制push后远程文件可能会丢失 不建议使用此方法)
$ git push -u origin master -f
最后完美运行
借鉴https://blog.youkuaiyun.com/aaaaaab_/article/details/82315116 中强制push本地仓库到远程