# Why isn't hook file cloned to bared repository ?

3 messages from 2009-03-04 to 2009-03-04. Participants: Emily Ren, Bryan Donlan, Johannes Schindelin.
Thread: https://gitlist.dev/t/18125

## Emily Ren, 2009-03-04 05:40

Subject: Why isn't hook file cloned to bared repository ?
Message-ID: <856bfe0e0903032140w4d8a9415l9f7b9a0678b492cc@mail.gmail.com>
URL: https://gitlist.dev/e/856bfe0e0903032140w4d8a9415l9f7b9a0678b492cc%40mail.gmail.com

```
Hi,

I added file "update" in my git repository my_repo/.git/hooks/,  then
I run command "git clone --bare my_repo" to generate a bared
repository my_repo.git. But there's no update in my_repo.git/hooks.

Do you know why ?

Thanks,
Emily

```

## Bryan Donlan, 2009-03-04 06:13

Subject: Re: Why isn't hook file cloned to bared repository ?
Message-ID: <3e8340490903032213u56734301o39c9d00633410fd5@mail.gmail.com>
URL: https://gitlist.dev/e/3e8340490903032213u56734301o39c9d00633410fd5%40mail.gmail.com
In-Reply-To: <856bfe0e0903032140w4d8a9415l9f7b9a0678b492cc@mail.gmail.com>

```
On Wed, Mar 4, 2009 at 12:40 AM, Emily Ren <lingyan.ren@gmail.com> wrote:
> Hi,
>
> I added file "update" in my git repository my_repo/.git/hooks/,  then
> I run command "git clone --bare my_repo" to generate a bared
> repository my_repo.git. But there's no update in my_repo.git/hooks.
>
> Do you know why ?

Because allowing code from an untrusted third-party repository to be
executed automatically without giving a chance to examine it is not a
very good idea from a security standpoint. In addition, hooks are
often not of interest to the person cloning the repository. Because of
these reasons, git clone will not copy hooks from the source
repository (for consistency, this is the case even when the source is
local).

```

## Johannes Schindelin, 2009-03-04 10:04

Subject: Re: Why isn't hook file cloned to bared repository ?
Message-ID: <alpine.DEB.1.00.0903041103270.8549@intel-tinevez-2-302>
URL: https://gitlist.dev/e/alpine.DEB.1.00.0903041103270.8549%40intel-tinevez-2-302
In-Reply-To: <3e8340490903032213u56734301o39c9d00633410fd5@mail.gmail.com>

```
Hi,

On Wed, 4 Mar 2009, Bryan Donlan wrote:

> On Wed, Mar 4, 2009 at 12:40 AM, Emily Ren <lingyan.ren@gmail.com> wrote:
>
> > I added file "update" in my git repository my_repo/.git/hooks/,  then
> > I run command "git clone --bare my_repo" to generate a bared
> > repository my_repo.git. But there's no update in my_repo.git/hooks.
> >
> > Do you know why ?
> 
> Because allowing code from an untrusted third-party repository to be
> executed automatically without giving a chance to examine it is not a
> very good idea from a security standpoint. In addition, hooks are
> often not of interest to the person cloning the repository. Because of
> these reasons, git clone will not copy hooks from the source
> repository (for consistency, this is the case even when the source is
> local).

I might add that hooks are not part of the repository.  They are not 
versioned, for example.

Having said that, nothing prevents you from committing a set of example 
hooks and a script to install them, and tell your users that they may 
install default hooks using that script.  I do that for one of my 
projects.

Ciao,
Dscho

```
