Reputation: 51884
I want to protect a specific local branch (e.g. master
) from being rebased accidentally. I know how to do this on the server side. Bitbucket has a configuration as shown in the screenshot.
How can I protect a local branch (e.g. master
) from being rebased as in ...?
$ git rebase feature master
Upvotes: 1
Views: 294
Reputation: 92884
Go through the following steps:
git config
list with the command: git config branch.master.rebaselock true
(along with master
could be any other branch)pre-rebase
git hook by Uasi: https://gist.github.com/uasi/9384329Upvotes: 3
Reputation: 38734
pre-rebase
hook is what you're after.
Here a quote from 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.
Upvotes: 2