Git使用记录

  • 查看本地管理的用户名和邮箱设置
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]
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值