- 查看本地管理的用户名和邮箱设置
git config --list
由于GitHub停用了用户名密码登录,改为了用户名token登录,所以在未进行token设置或者token过期的情况下,无法进行push操作,会提示
Authentication failed ...
此时需要打开github主页,点击头像-> Setting -> Developer Settings -> Personal Access Tokens -> generate new token (或许需要删除之前过期的token)
然后再次进行push操作,此时会弹出用户名和密码的命令,只需要填写用户名,并将刚刚的token复制即可。
当想要更新远程仓库的代码时,假设此时本地没有远程仓库对应的代码文件夹(指专门用来上传的版本),则步骤如下:
首先建立一个新的文件夹,cd进入,把远程仓库拉下来
git clone xxx (the link of the remote reporsitory)
cd该文件,将更新的文件贴进去覆盖,或者添加新的文件后,
git add .
git commit -m "[message]"
git push -u origin main
对于报错:remote: Write access to repository not granted.
说明生成的token忘记赋予权限,可以删除重新生成,记得打勾
对于报错:fatal: No configured push destination.
Either specify the URL from the command-line or configure a remote repository using
说明没有链接远程仓库,
git remote add origin [link]
对于报错:error: src refspec main does not match any
将本地的git仓库分支由默认master改为默认main
git branch -m master main
在进行push之前首先pull一下可以确保版本一致:
git pull [link]