Skip to main content
The apply command ensures that the specified targets are in the target state, updating them if necessary. This is the command that actually modifies files in your home directory to match your source state.

Usage

chezmoi apply [target]...

Description

The apply command updates the destination directory to match the target state defined in your source directory. If no targets are specified, chezmoi applies changes to all managed files. If a target has been modified since chezmoi last wrote it, you will be prompted to confirm whether you want to overwrite the file (unless --force is specified).

Flags

-x, --exclude
types
Exclude entry types (comma-separated: dirs, files, remove, scripts, symlinks, always, encrypted, externals, templates).
-i, --include
types
Include only specified entry types (comma-separated: dirs, files, remove, scripts, symlinks, always, encrypted, externals, templates).
--init
boolean
default:"false"
Recreate the config file from the template in the source directory. Useful when template data has changed.
-P, --parent-dirs
boolean
default:"false"
Apply changes to all parent directories of the specified targets.
-r, --recursive
boolean
default:"true"
Recurse into subdirectories.

Examples

Apply all changes

chezmoi apply
This updates your entire home directory to match the target state.

Dry run to see what would change

chezmoi apply --dry-run --verbose
Shows what changes would be made without actually making them.

Apply changes to a specific file

chezmoi apply ~/.bashrc

Apply with verbose output

chezmoi apply -v
Shows detailed information about what changes are being made.

Apply and recreate config

chezmoi apply --init
Useful when you’ve updated template data and want to regenerate your config file.

Behavior

Interactive Prompts

When a file has been modified locally and differs from both the target state and the last known state, chezmoi will prompt you to choose an action:
  • Yes - Overwrite the local file with the target state
  • No - Skip this file
  • All - Overwrite this and all subsequent files without prompting
  • Quit - Exit chezmoi immediately
Use --force to automatically overwrite without prompting.

Scripts

Scripts in your source state (files starting with run_) are executed when you apply changes. Scripts are only run once unless:
  • They have the always attribute (prefix run_always_)
  • You use the --force flag

Terminal Output

$ chezmoi apply -v
.bashrc: updating
.gitconfig: updating
.tmux.conf: no changes
run_once_install-packages.sh: running script
  • diff - Preview changes before applying
  • status - Check the status of managed files
  • update - Pull changes and apply them

Build docs developers (and LLMs) love