简体   繁体   English

绕过git服务器端钩子

[英]Bypass git server side hooks

When I try to push commits made by other people, git server rejects the commits with pre-receive hook declined: 当我尝试推送其他人的提交时,git server拒绝了带有预接收钩子的提交:

expected committer name 'John' but found 'Jill' 预期的提交者名称为“ John”,但找到了“ Jill”

Is there a way to bypass this server side hook without asking repo admin to change policy? 有没有一种方法可以绕过此服务器端挂钩,而无需要求仓库管理员更改策略?

I don't want to take credit for commits that other people have made. 我不想因为别人所做的承诺而功劳。 Also, this is a result of moving files with their histories from one repo to another. 同样,这是将文件及其历史记录从一个存储库移动到另一个存储库的结果。 I want to preserve said history. 我想保留所说的历史。

Is there a way to bypass [a] server side hook without asking repo admin to change policy? 有没有一种方法可以绕过[a]服务器端挂接,而不要求仓库管理员更改策略?

Not generally, no. 一般而言,不。 The specifics depend on the hook. 具体取决于钩子。 For instance, it's easy to write a server-side hook that rejects commits with the word fnord in the log message unless the word slack! 例如,很容易编写一个服务器端钩子, 除非日志中有单词slack! 否则它将拒绝日志消息中带有单词fnord提交slack! (complete with exclamation point) also appears somewhere in the log message. (带有感叹号) 出现在日志消息中的某处。 Hence it's possible that your server-side hook will allow a different committer-name if some other item is also set some specific way. 因此,如果还以其他特定方式设置了其他项,则服务器端挂钩可能会允许使用不同的提交者名称。

That said, though: 话虽如此:

I don't want to take credit for commits that other people have made. 我不想因为别人所做的承诺而功劳。

The committer in a commit is, deliberately, not the author of the commit. 提交中的提交者故意不是提交的作者 Every commit in git has two separate users—name, email address, and date—attached. git中的每个提交都附加了两个单独的用户-名称,电子邮件地址和日期。 One is the commit's author and the other is the committer . 一个是提交者的作者 ,另一个是提交者 Submitting a commit with you as the committer, and someone else as the author, is the standard way of declaring that the someone-else is the author of that commit, and you merely put it into the repository. 以您作为提交者,其他人作为作者的方式提交提交是声明其他人是该提交的作者的标准方法,而您只需将其放入存储库即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM