From a813fb6a627fb56f6102fb4e27beeae2ccc50e2b Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Mon, 16 Mar 2015 21:26:23 -0500 Subject: [PATCH] Add Dry Runs in Git as a git til. --- README.md | 1 + git/dry-runs-in-git.md | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 git/dry-runs-in-git.md diff --git a/README.md b/README.md index e7bfab9..9139cf5 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ smart people at [Hashrocket](http://hashrocket.com/). - [Checkout Previous Branch](git/checkout-previous-branch.md) - [Delete All Untracked Files](git/delete-all-untracked-files.md) +- [Dry Runs in Git](git/dry-runs-in-git.md) - [Intent To Add](git/intent-to-add.md) - [Staging Changes Within Vim](git/staging-changes-within-vim.md) - [Stashing Untracked Files](git/stashing-untracked-files.md) diff --git a/git/dry-runs-in-git.md b/git/dry-runs-in-git.md new file mode 100644 index 0000000..eb4e673 --- /dev/null +++ b/git/dry-runs-in-git.md @@ -0,0 +1,26 @@ +# Dry Runs in Git + +There are a few commands in git that allow you to do a *dry run*. That is, +git will tell you the effects of executing a command without actually +executing that command. + +For instance, if you are clearing out untracked files, you can double check +what files are going to be deleted with the *dry run* flag, like so: + +``` +$ git clean -fd --dry-run +Would remove tmp.txt +Would remove stuff/ +``` + +Similarly, if you want check which files a commit is going to incorporated, +you can: + +``` +$ git commit --dry-run --short +M README.md +A new_file.rb +``` + +Try running `git commit --dry-run` (that is, without the `--short` flag). +Look familiar? That is the same output you are getting from `git status`.