# git hooks to run something

3 messages from 2009-03-24 to 2009-03-25. Participants: Alf Clement, Jeff King.
Thread: https://gitlist.dev/t/18505

## Alf Clement, 2009-03-24 10:56

Subject: git hooks to run something
Message-ID: <556d90580903240356q3a72fd0bwa5ebe335914bc469@mail.gmail.com>
URL: https://gitlist.dev/e/556d90580903240356q3a72fd0bwa5ebe335914bc469%40mail.gmail.com

```
Hi all,

when I switch between branches, I would like like to delete some
object files and prepare some setup files.
I there a good way to do this automatically when I run "git checkout
branch", like
misusing a hook to run a make in a special directory?
All would happen in my local repository.

Thanks,
Alf

```

## Jeff King, 2009-03-24 11:15

Subject: Re: git hooks to run something
Message-ID: <20090324111524.GA6291@coredump.intra.peff.net>
URL: https://gitlist.dev/e/20090324111524.GA6291%40coredump.intra.peff.net
In-Reply-To: <556d90580903240356q3a72fd0bwa5ebe335914bc469@mail.gmail.com>

```
On Tue, Mar 24, 2009 at 11:56:05AM +0100, Alf Clement wrote:

> when I switch between branches, I would like like to delete some
> object files and prepare some setup files.
> I there a good way to do this automatically when I run "git checkout
> branch", like
> misusing a hook to run a make in a special directory?
> All would happen in my local repository.

There is a post-checkout hook; see "git help hooks" for details.

You could also make an alias; see the documentation for "alias.*" in
"git help config".

-Peff

```

## Jeff King, 2009-03-25 11:25

Subject: Re: git hooks to run something
Message-ID: <20090325112507.GA4437@coredump.intra.peff.net>
URL: https://gitlist.dev/e/20090325112507.GA4437%40coredump.intra.peff.net
In-Reply-To: <556d90580903250333l496520ao5fde64fb08faf9ae@mail.gmail.com>

```
[re-adding git@vger to cc; please keep questions on-list so that others
can also help to answer]

On Wed, Mar 25, 2009 at 11:33:39AM +0100, Alf Clement wrote:

> is there a way to push a modified hook script with the repository when
> I push it to a server?
> And how to get it with pull?

No; for security reasons, no code (including hooks) from remote
repositories is automatically run. The usual method is to include the
hook in your repository and copy it into place after cloning.

-Peff

```
