Skip to main content

9.2.1 Safety

This section discusses various variables that you might want to change (or not change) for safety reasons.

Git keeps committed changes around long enough for users to recover changes they have accidentally been deleted. It does not do the same for uncommitted changes in the working tree and not even the index (the staging area). Because Magit makes it so easy to modify uncommitted changes, it also makes it easy to shoot yourself in the foot in the process. For that reason Magit provides three global modes that save tracked files to work-in-progress references after or before certain actions. See Wip Modes.

These modes are not enabled by default because of performance concerns. Instead a lot of potentially destructive commands require confirmation every time they are used. In many cases this can be disabled by adding a symbol to magit-no-confirm (see Completion and Confirmation). If you enable the various wip modes then you should add safe-with-wip to this list.

Similarly it isn’t necessary to require confirmation before moving a file to the system trash - if you trashed a file by mistake then you can recover it from there. Option magit-delete-by-moving-to-trash controls whether the system trash is used, which is the case by default. Nevertheless, trash isn’t a member of magit-no-confirm - you might want to change that.

By default buffers visiting files are automatically reverted when the visited file changes on disk. This isn’t as risky as it might seem, but to make an informed decision you should see Risk of Reverting Automatically.