#2162·chezmoi

Inverse of "overwrite" (i.e. "accept") option for `chezmoi apply`

Author: msewellCreated Jun 20, 2022Updated Jun 8, 2026
Labelsenhancementv3

Is your feature request related to a problem? Please describe.

When running chezmoi apply and there has been an external modification to a chezmoi-managed file, chezmoi v2.17.2 will prompt what to do with the file:

bash
$ chezmoi apply
.iterm2/com.googlecode.iterm2.plist has changed since chezmoi last wrote it [diff,overwrite,all-overwrite,skip,quit]?

The command reference for "chezmoi apply" doesn't explain which file (the source (chezmoi state) or the target (local state)) gets overwritten when choosing the "overwrite" option, but after testing it I believe it is the target file that gets overwritten from the source.

For files which are most frequently changed externally, i.e. without use of chezmoi edit (in the example above, the iTerm2 configuration file, which reflects changes the user makes from the app's UI), overwriting the target file is likely to be the opposite of the desired action: it is the source file which should be updated from the target file's state.

From what I understand, users have to chezmoi add (actually re-add) each file for which they want chezmoi to accept the local state each time it changes. This is cumbersome, especially if there are many of these files.

Describe the solution you'd like

I believe adding "accept"/"all-accept" (or any other sensibly-named) prompts to the output of chezmoi apply which allows the target file(s) to overwrite the source file(s) when there are conflicts would be a significant QoL improvement.

bash
$ chezmoi apply 
.iterm2/com.googlecode.iterm2.plist has changed since chezmoi last wrote it [diff,overwrite,all-overwrite,accept,all-acceptskip,quit]?

(Also, documenting the semantics of each of these prompt options in the command reference for chezmoi apply would help.)

Describe alternatives you've considered

Instead of adding the "accept (all) local modifications" functionality to chezmoi apply, this could also be a new command or part of another command.

Additional context

Chances are I'm just misunderstanding how to get chezmoi to accept local changes to managed files, though.