Sometimes when running git commands, you might do stuff you didn’t intend. For instance when running git clean...
git clean -f
Whoops, you have just removed all untracked files from your working tree and even untracked folders (for instance a settings folder of your IDE).
Now this is where ‘dry run’ comes to the rescue. This option will check what the git command is about to do, before actually doing so. You’ll mostly be using the -n option like this:
git clean -n
Not every git command supports the -n option. It sometimes even means something else. For instance in the case of
git commit -n
, which is the –no-verify option, which bypasses the pre-commit and commit-msg hooks. In that case you should use
git merge --dry-run.
Many commands have a dry run option. To be safe, just check the help docs for the command you want to dry run to make sure you're dry-run ambitions don't end in frustration and redundant tears.
Have a nice day!