大佬们,怎么用技术手段限制 git push --force ,避免覆盖别人的提交?

2018-05-24 19:46:02 +08:00
 earther01
今天快要被这个问题搞死了,只要加上--force 就能强制覆盖远程仓库,导致别人的提交消失的无影无踪,从提交记录上还很难查到是谁进行了强制覆盖。
大佬们,有没有什么办法能禁止强制提交呢?
6259 次点击
所在节点    问与答
8 条回复
Xbluer
2018-05-24 19:50:58 +08:00
服务器端控制啊,gitlab 使用分支保护功能。
elgae
2018-05-24 19:55:53 +08:00
gerrit
earther01
2018-05-24 20:11:31 +08:00
@Xbluer gitlab 的分支保护功能好像没办法禁止 push -f 而开放普通 push,有什么特别的配置方法么
azh7138m
2018-05-24 20:16:50 +08:00
CFO
2018-05-24 20:42:13 +08:00
做分支保护 必须发起 pull request 才能合并
Jakesoft
2018-05-24 21:03:26 +08:00
@earther01 有的 admin 可以关掉
msg7086
2018-05-25 00:12:08 +08:00
@earther01
By default, protected branches are designed to:
prevent their creation, if not already created, from everybody except Masters
prevent pushes from everybody except Masters
-> prevent anyone from force pushing to the branch
-> prevent anyone from deleting the branch

把分支加入保护就可以了。
你说的开放普通 Push,就是把 Push 权限下放给 Developers。
如果要禁止普通 Push,把 Push 权限改成 Masters 就行了。

PS: force push 操作记录上是可以查出来的,某某人删除了多少个提交。
ShadowStar
2018-05-25 00:39:55 +08:00
在远程仓库配置 config:receive.denyNonFastForwards = true

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/457553

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX