为什么github允许无法识别的作者提交 [英] Why github allows unrecognized author to commit

查看:70
本文介绍了为什么github允许无法识别的作者提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我自己的GitHub存储库中,我注意到有来自无法识别的作者的提交.

我已经开始调查,并且意识到,当我通过 Visual Studio 2015-Team Explorer 在远程存储库上进行任何更改时,即使我更改了全局,更改也会被成功推送.gitconfig 设置,并在其中设置无效的用户名和无效的电子邮件地址-当我遇到无法识别的作者时就是这种情况.

如果我尝试通过 git bash 命令提示符直接推送更改,并输入无效的用户名或密码,我将得到:无效的用户名或密码-这很明显,并且正常.

然后我得到:如果我输入有效的用户名/密码,则请求的URL返回错误:403 -但这又是正常现象,因为我没有将此用户添加为我的 Collaborator .如果将此用户添加为协作者,则可以成功推送.

那么,为什么会这样呢?

为什么GitHub允许我使用无效的用户/电子邮件通过VS 2015推送更改?

解决方案

从根本上讲,git是分散式的.存储库的每个副本都彼此相等.提交可以从任何地方到任何地方.对于您来说,从远程X上提取提交并将其推送到远程Y上是完全正常的,并且当它们显示在远程Y上时,即使该人可能在远程Y上没有帐户,原始提交者的名称仍将保留在它们上./p>

远程Y(在本例中为github)因此不能仅仅因为其中包含一些无法识别的提交者名称而拒绝推送.

从命令行进行身份验证时,您无需输入用户名和密码即可将自己标识为被推送的提交者.您只是将自己标识为有权将这些提交放入存储库中的人.大概当您从IDE中进行操作时,它使用的是您在某个时候输入的github凭据.

On my own GitHub repository I've noticed that there are commits from unrecognized author.

I've started investigating and I realized that when I push any changes on my remote repository via Visual Studio 2015 - Team Explorer, the changes are pushed successfully even If I change my global .gitconfig settings and set there invalid username along with invalid e-mail address - this is the case when I get unrecognized author.

If I try to push the changes directly via git bash command prompt, and enter invalid username or password I'll get: invalid username or password - which is obvious, and normal.

And I get: The requested URL returned error: 403 if I enter valid user/pass - but again, this is normal because I haven't added this user as my Collaborator. If I add this user as my collaborator, I can push successfully.

So, why is this happening ?

Why GitHub allows me to push changes via VS 2015 with invalid user/email ?

解决方案

Fundamentally, git is decentralized. Every copy of the repository is equal to every other. Commits can go from anywhere to anywhere. It's perfectly normal for you to pull commits from remote X and push them to remote Y, and when they show up on remote Y, the original committer's name will still be on them even though that person may not have an account on remote Y.

Remote Y (github in this case) therefore can't refuse a push just because it contains some unrecognized committer names.

When you authenticate from the command line, you're not entering a username and password to identify yourself as the author of the commits being pushed. You're just identifying yourself as someone who has permission to put those commits in the repository. Presumably when you do it from the IDE, it is using your github credentials which you have entered at some point.

这篇关于为什么github允许无法识别的作者提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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