3 ms·
You can simply use `git add -p` to stage hunks individually (or `git reset -p` to unstage some hunks).
by ckuehl 11y ago
You can simply use `git add -p` to stage hunks individually (or `git reset -p` to unstage some hunks).
- deleted 11y ago[deleted]
- aninhumer 11y agoAnd `git checkout -p` to erase hunks from the working directory. (i.e. delete without saving!)
- icebraining 11y agoThat's a little dangerous! I use git stash -p instead, and only drop it after I'm absolutely sure.
- 0x0 11y ago"git add -p" can be fun, but it's a little scary because it's super easy to end up making commits that don't actually stand on their own. Super simple to miss an import here or a new field there. If you do a whole series of them, it might actually be worse for others to come back to (or bisect in) if they don't realize the original developer never actually compiled and tested each commit as-is.
- aninhumer 11y agoWell ideally you could use `git stash -k -u` (-keep index, stash -untracked) to set your working directory to the state you're actually committing, and then run some tests. For the most part though, I just try to avoid having so many hunks to step through that this is even an issue.