尽管git config和git remote没有引用它,但使用备用用户ID的Git [英] Git using alternate userid although git config and git remote do not reference it

查看:55
本文介绍了尽管git config和git remote没有引用它,但使用备用用户ID的Git的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个github id:javadxx和stephencompanyid.

I have two github ids: javadxx and stephencompanyid.

当尝试推送到下面的屏幕快照中所示的github存储库时,似乎应用了错误的用户名:意图是使用javadxx,但错误消息似乎表明已应用了另一个.

While attempting to push to the github repo shown in the screenshot below it seems the incorrect userid were applied: the intention is to use the javadxx but the error message seem to indicate the other one were applied.

以下是远程裁判:

$git remote -v
origin  https://github.com/javadxx/jfreechart-fse (fetch)
origin  https://github.com/javadxx/jfreechart-fse (push)

屏幕截图显示了叉子是在javadxx id下创建的:

Screenshot shows the fork was created under javadxx id:

这是尝试的命令:

6:40:01/jfreechart-fse $git push origin InitFromArray
remote: Permission to javadxx/jfreechart-fse.git denied to stephencompanyid.

奇怪的是,.gitconfig和本地git config -l均表示相反-即javadxx处于活动状态.

The strange thing is that both the .gitconfig and the local git config -l indicate otherwise - i.e. that the javadxx were active.

jfreechart-fse $git config user.name
javadxx
16:48:04/jfreechart-fse $git config user.email
javadxx@<blah>

内部.gitconfig:

[user]
    name = javadxx 
    email = javadxx@<blah>

我什至在.git文件夹中查找了其他ID的剩余部分:

I even looked inside the .git folder for any remnants of the other id:

grep companyname .git/*

(no results)

推荐答案

git config(和您的配置中)文件使用的数据用于创建提交的 author .您可以在其中放置任何内容-没关系,没有验证这实际上是您或任何其他有效地址.

The data used by git config (and in your config) file is used for creating the author of the commit. You can put in anything in there - it doesn't matter, there's no verification that this is actually you or any other valid address.

您看到的是推送到服务器的身份验证-由Git单独处理.根据您的操作系统,您的凭据可能会被缓存-这很可能是您在此处看到的.

What you are seeing is the authentication for pushing to the server - that's handled separately by Git. Depending on your operating system, your credentials may be cached - this is likely what you're seeing here.

Git附带一个 credential helper ,它将您的Git凭据存储在操作系统的凭据存储中(在Windows和Mac OS X上.Linux没有安全的Git凭据存储).

Git comes with a credential helper, which stores your Git credentials in the operating system's credential store (on Windows and on Mac OS X. Linux does not have a secure Git credential store).

要清除存储的身份验证数据,请在终端机/外壳程序窗口中键入以下内容(按 ENTER 键,其中显示<ENTER>):

To clear the stored authentication data, type the following in a terminal/shell window (hit the ENTER key where it says <ENTER>):

git credential reject<ENTER>
url=https://github.com<ENTER>
<ENTER>

这应该清除存储的信息,一旦您再次尝试按下,它应该再次要求输入用户名和密码.

This should clear the stored information, once you try to push again, it should ask for username and password again.

或者,您可以使用操作系统的凭据存储(例如,在Mac OS X中为 Keychain Access )来手动删除凭据.

Alternatively, you can use your operating system's credential store (e.g. Keychain Access on Mac OS X) to delete the credentials manually.

有关凭证存储的更多信息,请点击此处:

More info on the credential storage here:

  • https://git-scm.com/book/en/v2/Git-Tools-Credential-Storage
  • https://help.github.com/articles/caching-your-github-password-in-git/

这篇关于尽管git config和git remote没有引用它,但使用备用用户ID的Git的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆