rycus86 / githooks

Githooks: per-repo and global Git hooks with version control
MIT License
380 stars 19 forks source link

.githooks in Repro will not executed/copied. #156

Closed Rentsch closed 3 years ago

Rentsch commented 3 years ago

Hello Guys,

I have problems with the githooks.

When I clone a repository just my local hooks from "%user%/.githooks/templates/hooks" will be copied into the .git/hooks direcotry. The hooks that are part of the repository inside .githooks-directory will not copied into .git/hooks.

I do have "trust-all" inside .githooks. I do "git hooks trust" I do "git hooks accecpt [hooks], so state change to active.

But when I delete the repository and do a new git clone, the command "git hooks list" shows the hooks inside repository/.githooks are stated at "pending / new" and they will not be executed.

Do you have any Idea? Do I miss an import config part?

Thanks for your help Sebastian

rycus86 commented 3 years ago

Hello @Rentsch

When I clone a repository just my local hooks from "%user%/.githooks/templates/hooks" will be copied into the .git/hooks direcotry. The hooks that are part of the repository inside .githooks-directory will not copied into .git/hooks.

Yes, that is how this works. On Git init you get the hooks from the Git template directory (~/.githooks/templates/hooks) copied into the repository's .git/hooks folder, then they will find and execute the actual hooks from inside the .githooks folder from within the repository, see https://github.com/rycus86/githooks#layout-and-options

But when I delete the repository and do a new git clone, the command "git hooks list" shows the hooks inside repository/.githooks are stated at "pending / new" and they will not be executed.

As described in the https://github.com/rycus86/githooks#opt-in-hooks section, the trusted setting is per-repository, so when you delete and re-init or re-clone it, you'll have to accept it once to get it trusted, otherwise anyone could get you to clone their trusted-pretending but malicious repo and run some code on your machine.

Does this help?

Rentsch commented 3 years ago

Hello @rycus86, Thanks for your answer.

I thought I can use githooks to avoid to fogret to "activate/copie" git/hooks" by hand. But when i do re-clone i do not get any information or notification that there are not trusted git hooks. So have the same problem like before. When I forget to activate/trust them, they will not executed.

Is this correct or am i wrong? Is there kind of information?

greetings Sebastian

rycus86 commented 3 years ago

But when i do re-clone i do not get any information or notification that there are not trusted git hooks.

The first time the hooks run you should get a prompt asking if you are happy to accept them, is that not happening for you? Do you interact with Git from the command line or from a graphical client?