疯狂的企鹅

Crazy.Rico's Blog


  • 首页

  • 归档

  • 关于

  • 标签

  • 分类

  • links

  • 搜索

Mac之Git账号的坑

发表于 2017-06-04 更新于 2019-10-16 分类于 协作 , git 阅读次数:
本文字数: 1.6k 阅读时长 ≈ 1 分钟

Permission to xxx/xxxxx.git denied to username.

之前使用mac终端中的git时,输入了用户名和密码,现在换了新的用户名密码后,clone下来的代码,修改后push 却提示 remote: Permission to marspie/marspie-demo.git denied to yaonew.
fatal: unable to access ‘https://github.com/marspie/marspie-demo.git/': The requested URL returned error: 403
其中yaonew是我第一次使用的用户名,现在已经使用了新的用户了。尝试重新 ssh-keygen 生成密钥,github添加新的密钥,无果。

经过网络搜索,有提出同样问题的,但是回复寥寥无几且没有能真正解决问题的,于是变化思路查找:Mac多Git账号配置,找到了一个帖子:http://suqianghotel.com/2016/09/13/mac-mulit-git-account-config/ 在文章的末尾找到了GitHub 官网的帮助文档:
GitHub help

Updating credentials from the OSX Keychain

You’ll need to update your saved username and password in the git-credential-osxkeychain helper if you change your password or username on GitHub.

Updating your credentials via Keychain Access

  1. In Finder, search for the Keychain Access app.
  2. In Keychain Access, search for github.com.
  3. Find the “internet password” entry for github.com.
  4. Edit or delete the entry accordingly.

Deleting your credentials via the command line

Through the command line, you can use the credential helper directly to erase the keychain entry.

To do this, type the following command:

$ git credential-osxkeychain erase
host=github.com
protocol=https
[Press Return]

If it’s successful, nothing will print out. To test that it works, try and clone a repository from GitHub. If you are prompted for a password, the keychain entry was deleted.

重新 git push

$ git push origin master
Username for 'https://github.com': marspie
Password for 'https://marspie@github.com': 
Counting objects: 8, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (8/8), done.
Writing objects: 100% (8/8), 628 bytes | 0 bytes/s, done.
Total 8 (delta 5), reused 0 (delta 0)
remote: Resolving deltas: 100% (5/5), completed with 5 local objects.
To https://github.com/marspie/marspie-demo.git
   32fe0cd..0a71a8a  master -> master

OK 搞定, tag!

-------------本文结束感谢您的阅读-------------
Crazy Rico wechat
欢迎您扫一扫上面的微信公众号,订阅我的博客!
Crazy Rico 微信支付

微信支付

Crazy Rico 支付宝

支付宝

# git
Docker之旅-Docker入门
Error: Module version mismatch. Expected 48, got 46.
  • 文章目录
  • 站点概览
Crazy Rico

Crazy Rico

33 日志
17 分类
39 标签
RSS
GitHub FCC E-Mail 慕课网 阿里云
  1. 1. Permission to xxx/xxxxx.git denied to username.
  2. 2. Updating credentials from the OSX Keychain
  3. 3. Updating your credentials via Keychain Access
  4. 4. Deleting your credentials via the command line
  5. 5. 重新 git push
苏ICP备17004952号 © 2020 Crazy Rico | 90k | 1:22
由 Hexo 强力驱动 v3.9.0
|
主题 – NexT.Gemini v7.3.0
|
0%