mirror of
https://github.com/jbranchaud/til
synced 2026-01-06 16:48:01 +00:00
Add Dry Runs in Git as a git til.
This commit is contained in:
@@ -11,6 +11,7 @@ smart people at [Hashrocket](http://hashrocket.com/).
|
|||||||
|
|
||||||
- [Checkout Previous Branch](git/checkout-previous-branch.md)
|
- [Checkout Previous Branch](git/checkout-previous-branch.md)
|
||||||
- [Delete All Untracked Files](git/delete-all-untracked-files.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)
|
- [Intent To Add](git/intent-to-add.md)
|
||||||
- [Staging Changes Within Vim](git/staging-changes-within-vim.md)
|
- [Staging Changes Within Vim](git/staging-changes-within-vim.md)
|
||||||
- [Stashing Untracked Files](git/stashing-untracked-files.md)
|
- [Stashing Untracked Files](git/stashing-untracked-files.md)
|
||||||
|
|||||||
26
git/dry-runs-in-git.md
Normal file
26
git/dry-runs-in-git.md
Normal 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`.
|
||||||
Reference in New Issue
Block a user