Skip to main content

atmos git hooks install

Write local .git/hooks/<hook> shim scripts for the hooks configured under git.hooks. Each shim is a one-liner that delegates to atmos git hooks run, keeping all hook logic in atmos.yaml where it is versioned, shared, and executed through Atmos workflows and custom commands.

atmos git hooks install --help
 

Usage​

atmos git hooks install [hook-name...] [flags]

Given this configuration:

git:
hooks:
pre-commit:
command: atmos workflow pre-commit
commit-msg:
command: atmos workflow commit-msg -- "$1"

install writes a shim like this for each hook, pinned to the absolute path of the atmos binary that ran install:

#!/bin/sh
# Generated by Atmos. Do not edit.
atmos_bin='/usr/local/bin/atmos'
[ -x "$atmos_bin" ] || atmos_bin=atmos
exec "$atmos_bin" git hooks run pre-commit "$@"

When the pinned binary is no longer executable, the shim falls back to atmos on PATH.

Examples​

# Install all hooks configured under git.hooks
atmos git hooks install

# Install only specific hooks
atmos git hooks install pre-commit commit-msg

# Overwrite existing hooks
atmos git hooks install --force

Behavior​

  • Installs all configured hooks when no hook names are provided; only the requested hooks otherwise.
  • Validates each hook before writing its shim: exactly one of command or steps must be set, and a steps list must be a valid step list. An invalid hook fails the install.
  • Warns for names under git.hooks that are not Git hook names, because Git never runs such a hook.
  • Reports shims that are already installed when you re-run the command.
  • Refuses to overwrite an existing hook unless --force is passed.
  • Marks generated shim scripts executable.
  • Resolves the hooks directory through Git (git rev-parse --git-path hooks), so linked worktrees — where .git is a file and hooks live in the common dir — work correctly.
  • Does not manage core.hooksPath, but warns when it is set (for example, by Husky), because Git ignores .git/hooks/* shims in that case.
PATH and GUI Git clients

Shims run the absolute atmos path recorded at install time, so a GUI Git client (an IDE, Sourcetree) or a cron job whose PATH differs from your shell still finds it. The fallback to PATH applies when that binary was moved or removed. After you move or upgrade atmos to a new location, run atmos git hooks install again: it rewrites shims that Atmos generated without --force.

Arguments​

hook-name... (optional)

One or more Git hook names (pre-commit, commit-msg, pre-push, ...) to install. When omitted, all hooks configured under git.hooks are installed.

Flags​

--force / -f (optional)

Overwrite existing hook scripts. Without it, install refuses to replace a hook that already exists. Environment variable: ATMOS_GIT_HOOKS_FORCE