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

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

问题描述

在我自己的 GitHub 存储库中,我注意到有来自 unrecognized author 的提交.

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

我已经开始调查并意识到当我通过 Visual Studio 2015 - Team Explorer 在远程存储库上推送任何更改时,即使我更改了全局 ,更改也会成功推送.gitconfig 设置并在那里设置无效的用户名和无效的电子邮件地址 - 当我得到 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.

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

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.

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

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 ?

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

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

推荐答案

从根本上说,git 是去中心化的.存储库的每个副本都是相同的.提交可以从任何地方到任何地方.您从远程 X 拉取提交并将它们推送到远程 Y 是完全正常的,当它们出现在远程 Y 上时,即使该人可能没有远程 Y 上的帐户,原始提交者的姓名仍将在其上.

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.

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

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

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

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天全站免登陆