by Ryan Irelan
But it’s also important to test things before you do them so you can avoid things going wrong!
One way to do that in Git is to use the
--dry-run flag with
Let’s say I have a bunch of changes and I just want to check what will happen when I run
git-add to stage them for commit. Unstaging a staged change isn’t a big deal but I like to avoid problems (and fixing them!) if I can.
git add . --dry-run
Using this command I’m adding all changed files (the
. means everything) but I’m only doing a simulation. When this happens I’ll get a list of files that will be included in the add and staged for the next commit.
A handy tip for the next time you want to see what happens before you do it.