File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
1010
1111For a steady stream of TILs, [ sign up for my newsletter] ( https://tinyletter.com/jbranchaud ) .
1212
13- _ 1035 TILs and counting..._
13+ _ 1036 TILs and counting..._
1414
1515---
1616
@@ -242,6 +242,7 @@ _1035 TILs and counting..._
242242- [ Grep Over Commit Messages] ( git/grep-over-commit-messages.md )
243243- [ Ignore Changes To A Tracked File] ( git/ignore-changes-to-a-tracked-file.md )
244244- [ Include A Message With Your Stashed Changes] ( git/include-a-message-with-your-stashed-changes.md )
245+ - [ Include Or Exclude Remaining Patch Changes] ( git/include-or-exclude-remaining-patch-changes.md )
245246- [ Include Some Stats In Your Git Log] ( git/include-some-stats-in-your-git-log.md )
246247- [ Intent To Add] ( git/intent-to-add.md )
247248- [ Interactively Unstage Changes] ( git/interactively-unstage-changes.md )
Original file line number Diff line number Diff line change 1+ # Include Or Exclude Remaining Patch Changes
2+
3+ I often use ` git add --patch ` as a way of interactively staging changes for a
4+ commit. Git walks me through each individual chunk of changes—which it calls
5+ _ hunks_ —so that I can include it or exclude it.
6+
7+ Sometimes, like when I'm working with a ` yarn.lock ` file, there are a ton of
8+ computer-generated changes to a file that I don't want to individually confirm.
9+ One of the options while interactively staging is to hit ` a ` which will stage the current hunk and all later hunks for the current file.
10+
11+ A complementary scenario arises at times when working with a Rails ` schema.rb `
12+ file. There are a bunch of Postgres client-specific changes that I don't want
13+ to commit. Once I get to the ` schema.rb ` file, I can hit ` d ` to _ not_ stage
14+ this or all remaining hunks in the current file.
15+
16+ ```
17+ a - stage this hunk and all later hunks in the file
18+ d - do not stage this hunk or any of the later hunks in the file
19+ ```
20+
21+ This saves me from hitting ` y ` a dozen times to accept changes or hitting ` n ` a
22+ dozen times to decline changes.
23+
24+ See ` man git-add ` and look for the _ Interactive mode_ section for more details.
You can’t perform that action at this time.
0 commit comments