Copy git/hooks/pre-commit.sample.of-your-choice to your repository's .git/hooks/pre-commit file.
For example, to install the google-java-format pre-commit hook, copy git/hooks/pre-commit.sample.google-java-format to a file named pre-commit inside the .git/hooks directory inside the Git repository where you'd like the hook to apply.