chezmoi installieren: init, dotfiles add, apply auf neuem Rechner
Dotfiles in chezmoi-Quelle versionieren; neues Gerät: init + apply.
Neuer Laptop or a fresh OS install means copying ~/.zshrc, SSH config, and editor settings by hand. chezmoi keeps dotfile sources in Git: chezmoi add on the machine you use today, chezmoi init plus chezmoi apply on the next one. Dieser Leitfaden: Installation macOS/Linux, chezmoi init, dotfiles hinzufügen, edit/diff, erster apply auf neuem Rechner für hereink.
The query is how to install chezmoi manage dotfiles and apply on a new machine. You should finish with chezmoi installed, a initialized source tree, at least one config file under management, and a successful apply after cloning your source elsewhere.
Was chezmoi löst
Versioned dotfiles
Track ~/.gitconfig, shell rc, ~/.config/nvim, and friends in one Git repo instead of ad hoc backups. Changes diff cleanly and roll back across machines.
Templates and secrets
chezmoi supports templates (OS-specific paths) and pulling secrets from 1Password and similar—so you do not commit live tokens. Start with plain add, then move edits to chezmoi edit.
Upstream:
github.com/twpayne/chezmoi, docs atchezmoi.io. Runchezmoi --versionafter install.
chezmoi installieren
- 1macOS (Homebrew)
brew install chezmoi. Verify withwhich chezmoiandchezmoi --version. - 2Linux
Official installer:
sh -c "$(curl -fsLS get.chezmoi.io)" -- -b $HOME/.local/bin, then put$HOME/.local/binonPATH. Distro packages are listed on chezmoi.io. - 3First init
chezmoi initcreates the source tree under~/.local/share/chezmoi. If you already host dotfiles on GitHub:chezmoi init https://github.com/YOUR_USER/dotfiles.git.
Bestehende Dateien add
Paths in the source are relative to home. To manage your current ~/.zshrc:
chezmoi add ~/.zshrc
chezmoi cd
git status
git commit -m "Add zshrc"
git pushchezmoi add copies into the source with permissions preserved. After that, change configs with chezmoi edit ~/.zshrc (edit source, then apply to home) so home and source do not drift.
Lokal apply und Alltagsbefehle
chezmoi apply
chezmoi diff
chezmoi status
chezmoi updateRun chezmoi diff before chezmoi apply so you see what will overwrite live files.
Auf neuem Rechner wiederherstellen
- 1Install chezmoi
Same brew or get.chezmoi.io steps as above.
- 2Init your source
chezmoi init https://github.com/YOUR_USER/dotfiles.git. Private repos need SSH or HTTPS credentials already configured. - 3First apply
chezmoi apply -v. Dry-run first:chezmoi apply -nv. Drop-nonce the diff looks right. - 4Stay in sync
chezmoi updatepulls and applies; local changes go back viachezmoi re-addor edit, commit, and push.
vs manuelles rsync oder Git in ~
| Approach | Multi-machine | Permissions / templates |
|---|---|---|
| Manual cp / rsync | Easy to miss files | You track it |
| Git in home only | Works; easy to leak secrets | No built-in templating |
| chezmoi | init + apply / update | add, templates, secret hooks |
- Passt
- Several Mac/Linux machines, shared shell/editor/SSH setup, clear Git history for dotfiles.
- Passt nicht
- Single machine, tiny config, never reinstall—plain backup may be enough.
Edited ~/.zshrc but chezmoi status shows drift?
You changed the live file. Run chezmoi re-add ~/.zshrc to capture into source, or chezmoi apply to reset home from source (destroys uncommitted home edits—diff first).
How is this different from GNU stow?
stow symlinks a package tree into home; chezmoi keeps a separate source and applies it, with templates and cross-OS support. Pick one workflow.
Windows?
chezmoi supports Windows with different paths and shells—see chezmoi.io. WSL users often manage Linux home separately from Windows dotfiles.
Nach dem Config-Setup das System skizzieren
Once terminal and editor settings match, service boundaries still belong on a shared canvas. See Raum erstellen.