git错误

作者: hugemountain | 来源:发表于2021-07-15 14:20 被阅读0次

一、目录

git403错误

2-github需要token

二、git403错误

remote: Access denied
fatal: unable to access 'https://gitee.com。。。。':
The requested URL returned error: 403

参考

  1. https://blog.csdn.net/ouyang_peng/article/details/80983996
  2. 段桥123-cnblogs

清除用户名

git config --system --unset credential.helper命令可以清除

如果遇到权限问题

就找到安装目录,启动git bash

问题起源:

https方式每次都要输入密码,按照如下设置即可输入一次就不用再手输入密码的困扰而且又享受https带来的极速

设置记住密码(默认15分钟):

git config --global credential.helper cache
如果想自己设置时间,可以这样做:

git config credential.helper cache --timeout=3600'
这样就设置一个小时之后失效

长期存储密码:

git config --global credential.helper store
增加远程地址的时候带上密码也是可以的。(推荐)

http://yourname:password@git.oschina.net/name/project.git

真是后悔,图一时痛快,忽略了宝贵的“推荐”二字。
git config --global credential.helper store该命令可以将用户名和密码长期全局地长期地存储在客户端(实际是客户端所在电脑,并非git的任何目录下,也就是说,即使重装git,改密码也存在。),注意是全局地。
原作者不推荐的原因正是这个。因为,这里保存的账号和密码会自动应用到每一个git clone指令,如果想要克隆的不是该账号下的项目,就只会得到403错误。

下路给出正解:
方法一:
增加远程地址的时候带上密码也是可以的。(推荐)

http://yourname:password@git.oschina.net/name/project.git
这种方式会把改账号和密码也添加到~/.git-credentials。
方法二:
运行命令:rm ~/.git-credentials,删掉git config --global credential.helper store保存的账号和密码。回到每次输入用户名和密码。
~/.git-credentials

2-github需要token

参考remote: Support for password authentication was removed- 博客园- jeremylai

  • 错误:

remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.

  • 原因:github2021不支持用密码提交了,得生成token

token记录在微信上面

  1. 先在github里生成token
  2. 设置token,这里分成两种情况,代码已经有的,远程仓库地址添加token;没有代码的,在git clone添加token

修改远程仓库添加token

git remote set-url origin https://<your_token>@github.com/<USERNAME>/<REPO>.git

git clone 添加token

git clone https://<your_token>@github.com/<USERNAME>/<REPO>.git

可以正常提交了

三、

推荐方法:https://www.jianshu.com/p/33a827bf9be6

方法2:

参考:博客园Lacey的文章

image

tip:要在自己账号里生成,密钥

# Your local changes to the following files would be overwritten by merge

相关文章

  • Git 使用记录

    git 命令错误处理 git remote: HTTP Basic: Access denied 错误解决方案: ...

  • git pull时遇到error: cannot lock re

    在执行git pull时遇到如下错误: 遇到这个错误会导致git pull失败。 问题原因 这个git工程的.gi...

  • Git 使用笔记

    git pull 问题 今天在使用git pull拉取远程库版本时,出现如下错误: 按照错误提示,使用git pu...

  • git: port 9418错误

    yarn遇到git错误 The unauthenticated git protocol on port 9418...

  • git clone出现Permission denied (pu

    一、错误 git clone git@gitee.com:wangzaiplus/xxx.git, 出现Permi...

  • Git错误

    Pathspec 'xxx' is in submodule unable to index file 错误: 解...

  • git错误

    一、目录 git403错误[#git403%E9%94%99%E8%AF%AF] 2-github需要token[...

  • Git

    Git 403错误解决: 运行命令:rm ~/.git-credentials,删掉git config --gl...

  • Git: refusing to merge unrelated

    错误描述 执行命令git pull,git feach,git checkout 时,提醒fatal: refus...

  • [rejected] master->master(fe

    解决方案:在git push -u origin master的时候报这个错误,根据错误提示用了 git pull...

网友评论

      本文标题:git错误

      本文链接:https://www.haomeiwen.com/subject/ginppltx.html