git_hooks_trust_hooks.md

March 30, 2024 · View on GitHub

git hooks trust hooks

Trust all hooks which match the glob patterns or namespace paths.

Synopsis

Trust all hooks which match the glob patterns or namespace paths given by --patterns or --paths.

To see the namespace paths of all hooks in the active repository, see <ns-path> in the output of git hooks list.

Hook Namespace Path

The namespaced path of a hook file consists of <namespacePath>ns:<namespace>/<relPath>, where <relPath> is the relative path of the hook with respect to a base directory <hooksDir>. Note that a namespace path <namespacePath> always contains forward slashes as path separators (on any platform).

The following values are set for <namespace> and <hooksDir> in the following three cases:

For local repository hooks in <repo>/.githooks:

  • <hooksDir><repo>/.githooks
  • <namespace> ≔ The first white-space trimmed line in the file <hooksDir>/.namespace or ns:gh-self.

For shared repository hooks in <sharedRepo> with url <url>:

  • <hooksDir><sharedRepo>
  • <namespace> ≔ The first white-space trimmed line in the file <hooksDir>/.namespace or the first 10 digits of the SHA1 hash of <url>.

For previous replace hooks in <repo>/.git/hooks/<hookName>.replaced.githook:

  • <hooksDir><repo>/.git/hooks
  • <namespace>ns:gh-replaced

Glob Pattern Syntax

The glob pattern syntax supports the globstar (double star) syntax in addition to the syntax in 'https://golang.org/pkg/path/filepath/#Match'. Also you can use negation with a prefix '!', where the '!' character is escaped by '!'. Every pattern which does not start with the namespace suffix ns: is automatically treated as a relative pattern to the location of

git hooks trust hooks [flags]

Options

      --pattern stringArray   Specified glob pattern matching hook namespace paths.
      --path stringArray      Specified path fully matching a hook namespace path.
      --all                   If the action applies to all found hooks.
                              (ignoring `--patterns`, `--paths`)
      --reset                 If the matched hooks are set `untrusted`.
  -h, --help                  help for hooks

SEE ALSO

Auto generated by spf13/cobra