1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-03 23:28:02 +00:00

Add Dry Runs in Git as a git til.

This commit is contained in:
jbranchaud
2015-03-16 21:26:23 -05:00
parent f160701882
commit a813fb6a62
2 changed files with 27 additions and 0 deletions

View File

@@ -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)

26
git/dry-runs-in-git.md Normal file
View File

@@ -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`.