如何保护本地主分支不被重新设置?
How to protect a local master branch from being rebased?
我想保护特定的本地分支(例如 master
)不被意外地重新定位。我知道如何在服务器端执行此操作。 Bitbucket配置如截图所示。
我如何保护本地分支(例如 master
)不被重新设置基址,如...?
$ git rebase feature master
pre-rebase
钩子就是你想要的。
此处引用 https://git-scm.com/docs/githooks:
pre-rebase
This hook is called by git rebase and can be used to prevent a branch from getting rebased. The hook may be called with one or two parameters. The first parameter is the upstream from which the series was forked. The second parameter is the branch being rebased, and is not set when rebasing the current branch.
完成以下步骤:
- 使用以下命令将特定设置添加到您的
git config
列表:git config branch.master.rebaselock true
(连同 master
可以是任何其他分支)
- 使用
pre-rebase
git Uasi 挂钩:https://gist.github.com/uasi/9384329
我想保护特定的本地分支(例如 master
)不被意外地重新定位。我知道如何在服务器端执行此操作。 Bitbucket配置如截图所示。
我如何保护本地分支(例如 master
)不被重新设置基址,如...?
$ git rebase feature master
pre-rebase
钩子就是你想要的。
此处引用 https://git-scm.com/docs/githooks:
pre-rebase
This hook is called by git rebase and can be used to prevent a branch from getting rebased. The hook may be called with one or two parameters. The first parameter is the upstream from which the series was forked. The second parameter is the branch being rebased, and is not set when rebasing the current branch.
完成以下步骤:
- 使用以下命令将特定设置添加到您的
git config
列表:git config branch.master.rebaselock true
(连同master
可以是任何其他分支)
- 使用
pre-rebase
git Uasi 挂钩:https://gist.github.com/uasi/9384329