Now that you know how to add files, use templates, and exclude things — it's time to learn the workflow you'll actually use every day. This lesson covers the core loop: edit a managed file, preview what changed, apply it, and sync with your remote repo.
Your chezmoi workflow boils down to four steps, repeated whenever you tweak a dotfile:
The chezmoi edit command opens the source state version of a file in your editor. This is the correct way to make changes — you're editing the source of truth, not the target file directly.
chezmoi edit ~/.zshrc
This opens ~/.local/share/chezmoi/dot_zshrc (or the template version if one exists) in your $EDITOR. Make your changes, save, and quit.
If you edit ~/.zshrc directly, chezmoi doesn't know about the change. The next time you run chezmoi apply, it will overwrite your edit with whatever is in the source state. Always edit through chezmoi or re-add the file after editing.
Before applying anything, see exactly what will change in your home directory:
chezmoi diff
This shows a unified diff between the source state and the current target. If you're happy with the changes, proceed to apply. If something looks wrong, go back and edit again.
Push the source state into your home directory:
chezmoi apply
This updates every managed file in your home directory to match the source state. It's idempotent — running it multiple times with no source changes does nothing.
If you only want to apply one file: chezmoi apply ~/.zshrc. Useful when you're mid-edit on multiple files and want to apply incrementally.
The source state is a git repo. Commit your changes and push to your remote:
chezmoi cd
git add .
git commit -m "chore: update zshrc aliases"
git push
exit
Or use the shorthand without entering the source directory:
chezmoi git -- add .
chezmoi git -- commit -m "chore: update zshrc aliases"
chezmoi git -- push
If you want to skip the separate diff and apply steps, use --apply to apply immediately after your editor closes:
chezmoi edit --apply ~/.zshrc
This is a single command that opens the file, waits for you to save and quit, then applies the changes to the target. It's convenient for quick tweaks where you trust the edit. Skip it when you want to review the diff first.
For a quick overview of what's changed without the full diff output, use status:
chezmoi status
This prints a concise list of files that differ between source and target, with single-character indicators:
M home/dot_zshrc
A home/dot_config/starship.toml
The indicators follow the same convention as git status: A for added, M for modified, D for deleted. It's the fastest way to see if your source and target are in sync.
When you've pushed changes from one machine and want to pull them on another, use update:
chezmoi update
This is the equivalent of git pull + chezmoi apply in a single command. It pulls the latest changes from your remote repo into the source state, then applies them to your home directory.
If you want to see what's coming before it lands on your system, split it into two steps: chezmoi git -- pull followed by chezmoi diff, then chezmoi apply once you're satisfied.
There are three common ways to get a change into chezmoi. Here's when to use each:
| Workflow | Commands | Best for |
|---|---|---|
chezmoi edit |
edit → diff → apply |
Planned changes where you want to review before applying |
chezmoi edit --apply |
edit --apply |
Quick tweaks where you trust the edit — skips the review step |
chezmoi re-add |
Edit target directly → re-add |
When you edited the target file by accident or a tool changed it |
chezmoi re-add copies the target back into the source state — the reverse of apply. Use it to capture changes you made directly to ~/.zshrc (or that a tool made). It overwrites the source with the current target content.
Practice the complete cycle with a managed file:
Open a managed file (use any file you've already added in previous lessons):
chezmoi edit ~/.gitconfig
Add a comment or an alias — something small and verifiable:
# Added via chezmoi edit workflow
[alias]
st = status
Save and quit your editor.
Preview the change:
chezmoi diff
You should see your new lines as additions in the diff output.
chezmoi apply
Verify the change landed:
cat ~/.gitconfig | grep "st = status"
chezmoi git -- add .
chezmoi git -- commit -m "chore: add git status alias"
chezmoi git -- push
chezmoi status
This should produce no output — source and target are in sync, and everything is committed.
chezmoi edit ~/.zshrc actually open?chezmoi edit opens the source state version. That's the whole point — you edit the source of truth, then apply it to the target.chezmoi edit opens the source state file (e.g., ~/.local/share/chezmoi/dot_zshrc). If you edit the target directly, chezmoi won't know about the change.chezmoi update do?update is git pull + apply combined. It's what you run on a second machine to pull changes you pushed from the first.chezmoi update pulls from your remote repo and then applies those changes to your home directory. It's the receiving end of the push you did on another machine.chezmoi re-add instead of chezmoi edit?re-add copies the target back into the source — it's for capturing changes that happened outside of chezmoi's workflow (manual edits, tool-generated changes, etc.).re-add is for when the target was changed directly (by you or a tool) and you want to sync that change back into the source state. It's the reverse of apply.You now have the complete daily workflow: edit, diff, apply, commit. In Lesson 8: Run Scripts Deep Dive, you'll learn how to automate tasks that go beyond file management — installing packages, setting defaults, and running setup commands as part of chezmoi apply.
chezmoi Daily Operations — The official guide to everyday chezmoi usage. Covers edit, diff, apply, update, and more. ~5 minute read.