init command sets up the source directory, optionally clones a repository, generates the config file, and optionally applies the changes to your system.
Usage
Description
Theinit command performs the following steps in order:
-
Initialize the source directory - If chezmoi does not detect a Git repository in the source directory, chezmoi will clone the provided
repointo the source directory. If norepois provided, chezmoi will initialize a new Git repository. -
Generate config file - If the initialized source directory contains a
.chezmoi.$FORMAT.tmplfile, a new configuration file will be created using that file as a template. -
Apply changes (if
--applyis set) - Runchezmoi applyto update the destination directory. -
Purge (if
--purgeis set) - Remove the source, config, and cache directories. -
Purge binary (if
--purge-binaryis set) - Attempt to remove the chezmoi binary itself.
Repository URL Guessing
By default, if a repo argument is given, chezmoi will guess the full git repo URL using HTTPS (or SSH with--ssh), according to these patterns:
| Pattern | HTTPS Repo | SSH Repo |
|---|---|---|
user | https://github.com/user/dotfiles.git | [email protected]:user/dotfiles.git |
user/repo | https://github.com/user/repo.git | [email protected]:user/repo.git |
site/user/repo | https://site/user/repo.git | git@site:user/repo.git |
sr.ht/~user | https://git.sr.ht/~user/dotfiles | [email protected]:~user/dotfiles |
sr.ht/~user/repo | https://git.sr.ht/~user/repo | [email protected]:~user/repo |
--guess-repo-url=false.
Flags
Run
chezmoi apply after checking out the repo and creating the config file.Check out the specified branch instead of the default branch.
Write the generated config file to the specified path instead of the default location.
Include existing template data when creating the config file. Set to
false to simulate creating the config file with no existing template data.Clone the repo with the specified depth (creates a shallow clone).
Run
git lfs pull after cloning the repo.Guess the repo URL from the repo argument.
Equivalent to
--apply --depth=1 --force --purge --purge-binary. Attempts to install your dotfiles with chezmoi and then remove all traces of chezmoi from the system. Useful for temporary environments like Docker containers.Remove the source and config directories after applying.
Attempt to remove the chezmoi binary after applying.
Recursively clone submodules.
Guess an SSH repo URL instead of an HTTPS repo URL.
Exclude entry types (comma-separated:
dirs, files, remove, scripts, symlinks, always, encrypted, externals, templates).Include only specified entry types (comma-separated:
dirs, files, remove, scripts, symlinks, always, encrypted, externals, templates).