Skip to content

Instantly share code, notes, and snippets.

@uasi
Last active February 13, 2023 13:30
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save uasi/9384329 to your computer and use it in GitHub Desktop.
Save uasi/9384329 to your computer and use it in GitHub Desktop.
A pre-rebase hook that refuses to rebase if "branch.${BRANCH}.rebaselock" is true.
#!/bin/sh
#
# The "pre-rebase" hook is run just before "git rebase" starts doing
# its job, and can prevent the command from running by exiting with
# non-zero status.
#
# The hook is called with the following parameters:
#
# $1 -- the upstream the series was forked from.
# $2 -- the branch being rebased (or empty when rebasing the current branch).
#
branch="$2"
[ -n "$branch" ] || branch=`git rev-parse --abbrev-ref HEAD`
lock="branch.${branch}.rebaselock"
if [ x`git config --bool "$lock"` = xtrue ]; then
echo "pre-rebase hook: \"$lock\" is set to true. Refusing to rebase."
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment