GitHub 在 Android 工作室

GitHub on Android Studio

我有一个多人共享的主 GitHub 帐户,我们每个人都有自己的帐户。我使用主帐户通过 Android Studio 创建了一个存储库,现在我要从我的个人帐户推送代码。所以我转到 File > Settings 下的 GitHub 设置并更改登录凭据以反映我的个人帐户。但是,当我推送代码时,它仍然说提交是由主帐户进行的,并且它是唯一的贡献者。我做错了什么?

也许当您使用新帐户设置 git 时它并没有改变 gitconfig

尝试:

git config --global user.name "Amir"
git config --global user.email "your_email@example.com"

(注意 --global 是可选的,它将使您的 name/email 在系统的任何地方)

的确,@LeonardoC 的解决方案解决了这个问题,但如果您想知道为什么会这样,您可以阅读以下内容:https://help.github.com/articles/why-are-my-commits-linked-to-the-wrong-user/

特别是说的部分:

GitHub uses the email address in the commit header to link the commit to a GitHub user. If your commits are being linked to another user, or not linked to a user at all, you may need to change your local Git configuration settings, add an email address to your account email settings, or do both.

Note: If your commits are linked to another user, that does not mean the user can access your repository. A user can only access a repository you own if you add them as a collaborator or add them to a team that has access to the repository

因此,要更改本地 Git 配置设置,请输入 @LeonardoC 提到的两条指令:

git config --global user.name "yourUsername"
git config --global user.email "theEmailLinkedToYourUsername"

如果您想在更改值之前检查值是什么,只需输入 shell:

即可获取它们
git config --global user.name
git config --global user.email