我怎样才能找出谁在 git 中强制推送?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15028246/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I find out who force pushed in git?
提问by glevine
Someone used git push --force
but I can't tell who did it from the logs. Is there a way to identify the culprit?
有人使用过,git push --force
但我无法从日志中看出是谁做的。有没有办法确定罪魁祸首?
回答by VonC
Update Nov. 2018: if you are pushing to a centralized Git repository hosting service like GitHub, thenyou would be able to see who has forced push your branch. But only because GitHub has chosen to surface that event in its GUI.
2018 年 11 月更新:如果您要推送到像 GitHub 这样的集中式 Git 存储库托管服务,那么您将能够看到谁强制推送了您的分支。但仅仅是因为 GitHub 选择在其 GUI 中显示该事件。
See more at "Find committer of a force push on GitHub".
请参阅“在 GitHub 上查找强制推送的提交者”。
Original answer 2013:
2013 年的原始答案:
As I mention in "Distributed Version Control Systems and the Enterprise - a Good mix?", there is no authorization or authentication with Git alone.
正如我在“分布式版本控制系统和企业 - 一个好的组合?”中提到的,单独使用 Git 没有授权或身份验证。
You need an authorization layerlike Gitolitein order to keep track of who does what. (Gitolite comes with its own audit trail mechanism).
你需要一个像Gitolite这样的授权层来跟踪谁做了什么。(Gitolite 带有自己的审计跟踪机制)。
But if your repo is accessible through file (or local) protocol, then you cannot know who forced pushed.
但是,如果您的存储库可以通过文件(或本地)协议访问,那么您将无法知道是谁强制推送的。
(from motivationalgenerator.com, and wikipedia)
回答by Pierrick HYMBERT
If you are luckyenough to use GitHubor GitHub for Enterprise, you can have a look to the eventsREST API and check who/when Pushed/Droppedto the remote refs, example for log4j:
如果您有幸使用GitHub或GitHub for Enterprise,您可以查看事件REST API 并检查谁/何时推送/删除到远程引用,例如 log4j: