I have a central bare repository in which a team publish (push) their commits. In this main repository, I want to disable the tag deletion and renaming.
Is there a solution like a hook or something ?
Protected tags allow control over who has permission to create or update Git tags. Each rule allows you to match either an individual tag name, or use an appropriate pattern to control multiple tags at once.
Select and expand the "Tags" tab on the left. Right-Click on the tag you want deleted. Select "Delete YOUR_TAG_NAME" In the verification window, select "Remove Tag From Remotes"
git help hooks
contains documentation about the hooks. The update
hook is invoked when Git is about to create/move/delete a reference. It is called once per reference to be updated, and is given:
If the hook exits with a non-zero exit code, git
won't update the reference and the user will get an error.
So to address your particular problem, you can add the following to your update
hook:
#!/bin/sh
log() { printf '%s\n' "$*"; }
error() { log "ERROR: $*" >&2; }
fatal() { error "$*"; exit 1; }
case $1 in
refs/tags/*)
[ "$3" != 0000000000000000000000000000000000000000 ] \
|| fatal "you're not allowed to delete tags"
[ "$2" = 0000000000000000000000000000000000000000 ] \
|| fatal "you're not allowed to move tags"
;;
esac
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With