How can I prevent non-fastforward pushes to selected branch(es) in git?

前端 未结 7 1268
醉话见心
醉话见心 2020-12-10 06:46

I would like to protect my git repository so only non master branches can be overwritten. Is there a way to protect only selected branches?

7条回答
  •  隐瞒了意图╮
    2020-12-10 07:26

    If you would be allowed to modify your server, then this will enable fast-forwarding on server.

    ssh ip 'echo $"[receive]
        denyDeletes = false
        denyNonFastForwards = false" >> /path/to/repo/config'
    #then git push -f origin master
    

提交回复
热议问题