earther01
V2EX  ›  问与答

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

  •  
  •   earther01 · May 24, 2018 · 7294 views
    This topic created in 2916 days ago, the information mentioned may be changed or developed.
    今天快要被这个问题搞死了,只要加上--force 就能强制覆盖远程仓库,导致别人的提交消失的无影无踪,从提交记录上还很难查到是谁进行了强制覆盖。
    大佬们,有没有什么办法能禁止强制提交呢?
    8 replies    2018-05-25 00:39:55 +08:00
    Xbluer
        1
    Xbluer  
       May 24, 2018 via iPhone
    服务器端控制啊,gitlab 使用分支保护功能。
    elgae
        2
    elgae  
       May 24, 2018 via Android
    gerrit
    earther01
        3
    earther01  
    OP
       May 24, 2018 via iPhone
    @Xbluer gitlab 的分支保护功能好像没办法禁止 push -f 而开放普通 push,有什么特别的配置方法么
    azh7138m
        4
    azh7138m  
       May 24, 2018 via Android   ❤️ 1
    CFO
        5
    CFO  
       May 24, 2018 via Android
    做分支保护 必须发起 pull request 才能合并
    Jakesoft
        6
    Jakesoft  
       May 24, 2018 via iPhone
    @earther01 有的 admin 可以关掉
    msg7086
        7
    msg7086  
       May 25, 2018
    @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
        8
    ShadowStar  
       May 25, 2018
    在远程仓库配置 config:receive.denyNonFastForwards = true
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2588 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 40ms · UTC 15:27 · PVG 23:27 · LAX 08:27 · JFK 11:27
    ♥ Do have faith in what you're doing.