我可以将ssh用户名与git通过ssh进行提交相关联吗? [英] Can I associate ssh username with commit with git over ssh?

查看:194
本文介绍了我可以将ssh用户名与git通过ssh进行提交相关联吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过ssh设置一个共享的git仓库,将用户的公钥复制到authorized_keys。我真的很喜欢ssh-key中的username作为repo中提交历史记录的一部分(这样用户joe不能只将他的名字设置为kate) - 我们需要某种责任) 。有没有办法做到这一点?

I am trying to setup a shared git repository via ssh, copying users public keys to the authorized_keys. I'd really like the "username" from the ssh-key to be part of the commit history in the repo (so that the user "joe" cannot just set his name to be "kate" - we need some kind of accountability). Is there any way to do this ?

推荐答案

简单地说,不,没有办法。原因在于作者和提交者的详细信息是在进行提交时设置的,并且通常发生在本地。稍后会发生 git push ,以将现有提交推送到远程存储库。由于提交已经被SHA1哈希引用并被引用,所以在推送操作期间它们不能被改变。

Simply, no, there is no way. The reason is that the author and committer details are set when a commit is made and this usually happens locally. A git push happens at a later time to push existing commits to the remote repository. Because the commits are already made and referenced by SHA1 hash, they cannot be altered during a push operation.

你可能会考虑做的事情是做一个预接收或更新钩子这可以防止人们推送他们还没有创作的提交,但这可能会阻止很多合法用途。您可能会发现信任您的用户是唯一明智的选择。

What you might consider doing is having a pre-receive or update hook that prevents people from pushing commits that they haven't authored, but this might prevent a lot of legitimate uses. You may find that trusting your users is the only sensible option.

这篇关于我可以将ssh用户名与git通过ssh进行提交相关联吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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