【问题标题】:How to protect a local master branch from being rebased?如何保护本地 master 分支不被 rebase?
【发布时间】:2016-05-11 07:42:53
【问题描述】:

我想保护一个特定的本地分支(例如master)不被意外地重新定位。我知道如何在服务器端执行此操作。 Bitbucket 的配置如截图所示。

如何保护本地分支(例如master)不被重新设置为...?

$ git rebase feature master

【问题讨论】:

    标签: git git-branch rebase git-config


    【解决方案1】:

    执行以下步骤:

    • 使用以下命令将特定设置添加到您的git config 列表:git config branch.master.rebaselock true(与master 一起可以是任何其他分支)
    • 使用 pre-rebase Uasi 的 git hook:https://gist.github.com/uasi/9384329

    【讨论】:

      【解决方案2】:

      pre-rebase 钩子是你所追求的。

      这里引用https://git-scm.com/docs/githooks

      预变基

      此钩子由 git rebase 调用,可用于防止分支重新设置基准。可以使用一个或两个参数调用该钩子。第一个参数是该系列被分叉的上游。第二个参数是要rebase的分支,rebase当前分支时不设置。

      【讨论】:

        猜你喜欢
        • 2019-12-16
        • 1970-01-01
        • 2022-01-15
        • 2012-09-05
        • 2015-10-31
        • 2012-07-03
        • 1970-01-01
        • 1970-01-01
        • 2011-11-04
        相关资源
        最近更新 更多