How can I copy .git/hooks/pre-receive to master branch(server repository is configured on linux) ?
Log in to the linux server. Copy the file to the appropriate directory. If you need the transfer the file, use whatever mechanism you have set up for that purpose (ftp, ssh, file servers, etc.).
Are there any configuration settings to ignore .git automatically ? Can I change that ?
No. by design no part of the .git
folder is shared by push/pull. That hooks are included in that is most definitely deliberate. It is not configuration; it is the design of git.
You might be able to confuse git by toying with the "git directory" environment variable in some way, but if this were ever shown to somehow write to the server's metadata directory, it would be considered an exploit - not a configuration change - and git would soon be patched to prevent it. (It probably already can't be done, but who knows what one might find prying at the edges of a system...?)
.git/hooks/pre-receive should exist in master repository only as this is triggered by server when git push is executed
Which as good a reason as any that you can't push
it to the server; that implies it exists on the clients as well.
By the way, the source repository is conventionally called origin
, not master
. master
refers to the default name of the default branch and exists in all repos. Although this is all configurable, using the terms in the conventional way is advisable to keep communications clearly understood.