diff --git a/README.md b/README.md index 9e4bc1e..75a380a 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ pairing with smart people at Hashrocket. For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186). -_1154 TILs and counting..._ +_1155 TILs and counting..._ --- @@ -228,6 +228,7 @@ _1154 TILs and counting..._ - [Checkout Previous Branch](git/checkout-previous-branch.md) - [Cherry Pick A Range Of Commits](git/cherry-pick-a-range-of-commits.md) - [Clean Out All Local Branches](git/clean-out-all-local-branches.md) +- [Clean Out Working Copy With Patched Restore](git/clean-out-working-copy-with-patched-restore.md) - [Clean Up Old Remote Tracking References](git/clean-up-old-remote-tracking-references.md) - [Clone A Repo Just For The Files, Without History](git/clone-a-repo-just-for-the-files-without-history.md) - [Clone A Repo Locally From .git](git/clone-a-repo-locally-from-git.md) diff --git a/git/clean-out-working-copy-with-patched-restore.md b/git/clean-out-working-copy-with-patched-restore.md new file mode 100644 index 0000000..dc337b9 --- /dev/null +++ b/git/clean-out-working-copy-with-patched-restore.md @@ -0,0 +1,27 @@ +# Clean Out Working Copy With Patched Restore + +I sometimes let the working copy of my projects get a little messy. The working +copy is all the changes I've made to tracked files that haven't been staged or +commited. + +After working for a bit, especially on something more exploratory, I end up +with comments, log statements, and debugging calls scattered across a bunch of +files. + +If these exploratory changes are mixed in with a bunch of actual changes, it +can create a lot noise. I can clean up that noise by restoring the files. I can +be surgical about it with the `--patch` flag. + +```bash +$ git restore --patch +``` + +This will prompt me for each changeset. + +- `y` -- yes, restore that change +- `n` -- no, leave it there +- `q` -- bail out of the restore + +There are other _patch_ options, but these are the ones I use the most. To see +what the rest of the options are, go to `man git-add` and find `patch` in the +`INTERACTIVE MODE` section.