eee*_*jay 68 git credentials github
我在Windows 7上使用git bash.我们使用github作为我们的存储库源.
每次我推或拉我都必须提供用户和密码凭据.我知道我的SSH密钥设置正确,否则我将无法访问存储库.(也就是说,一旦我输入我的凭证,推/拉工作正常.)
我进去了
git config --global user.name myusername
git config --global user.email myemail
git config --global github.user myusername
git config --global github.token mytoken
Run Code Online (Sandbox Code Playgroud)
但是,尽管如此,每次推/拉时都要求我提供凭据.
man*_*lds 54
确保您使用ssh url作为github repo而不是https url.当您使用https而不是SSH时,它会询问用户名和密码.您可以检查文件.git/config或运行git config -e或git remote show origin验证网址,并在需要时进行更改.
Ice*_*nte 44
从git bash我更喜欢运行命令:
git config --global credential.helper wincred
Run Code Online (Sandbox Code Playgroud)
此时运行命令git pull并输入您的凭证一次应将其存储以备将来使用.Git有一个内置的凭证系统,可以在不同的操作系统环境中运行.您可以在此处获取更多详细信息:https://git-scm.com/book/en/v2/Git-Tools-Credential-Storage
Che*_*胡晨海 17
对于那些使用访问令牌和Windows环境的人,有一种简单的方法可以做到这一点:
开始菜单→ 凭据管理器 → Windows凭据 →查找行(Git:https:// whatever / your-repository / url)→编辑, 用户名是PersonalAccessToken,密码是您的访问令牌。
小智 8
如果您是Mac用户并启用了钥匙串,则需要删除钥匙串中存储的授权信息:
- Open up Keychain access
- Click "All items" under category in the left-hand column
- Search for git
- Delete all git entries.
Run Code Online (Sandbox Code Playgroud)
然后,您应该使用git config以下命令从终端更改用户名和电子邮件:
$ git config --global user.name "Bob"
$ git config --global user.email "bob@example.com"
Run Code Online (Sandbox Code Playgroud)
现在,如果您尝试推送到存储库,将要求您输入用户名和密码。输入您要切换到的登录凭据。如果您使用其他用户名和密码或终端上先前切换的帐户在浏览器上登录GitHub,则通常会弹出此问题。
小智 6
添加远程为:
git remote add https://username:password@github.com/repodir/myrepo.git
Run Code Online (Sandbox Code Playgroud)
小智 5
我在另一个答案中写了一个答案:How to change git account in Git bash?
不过,我也在这里分享。
更改用户名和电子邮件全局
git config --global user.name "<username>"
git config --global user.email "<email>"
Run Code Online (Sandbox Code Playgroud)
更改当前存储库的用户名和电子邮件
git config user.name "<username>" --replace-all
git config user.email "<email>" --replace-all
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
302676 次 |
| 最近记录: |