ericleit
ericleit

Reputation: 321

Is there a git hook that will run after a branch delete?

I want to have run a script as a git hook specifically after a branch delete. Is there one for this?

Upvotes: 5

Views: 3783

Answers (1)

qqx
qqx

Reputation: 19475

No, there isn't a hook specifically for that.

If you're wanting something to be done after a branch is deleted via a push operation, you could use a post-receive hook on the server. When a push is done to that repository the hook would be called and receive on its standard input a series of lines describing the updates being done listing the previous head of the branch, the new head of the branch, and the ref name. For a delete, the new head would be a series of all zeros.

For deleting branches locally using the -d or -D options of git branch you could write a wrapper around that command to do whatever you want after that command has run, then train yourself to use that wrapper rather than the standard git command for doing that.

Upvotes: 5

Related Questions