Skip to content

Instantly share code, notes, and snippets.

@ismaelhamed
Forked from uasi/rebaselock.pre-rebase.sh
Last active September 29, 2016 05:47
Show Gist options
  • Save ismaelhamed/2aa4b9040a74183a1d18dc8585e86b5b to your computer and use it in GitHub Desktop.
Save ismaelhamed/2aa4b9040a74183a1d18dc8585e86b5b to your computer and use it in GitHub Desktop.
A pre-rebase hook that refuses to rebase if "branch.${BRANCH}.rebaselock" is true.
git config branch.master.rebaselock 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