3 ms·
I use `git add -p` to selectively pick out chunks of code that fit together into commits. Later on, if I notice that I messed something up, I'll create a fixup
by war1025 8y ago
I use `git add -p` to selectively pick out chunks of code that fit together into commits.
Later on, if I notice that I messed something up, I'll create a fixup commit and do an interactive rebase to squash it back into the correct commit.
- e3b0c 8y agoIn my opinion, `git add -p` should be the default, and a `-a` or alike to forcibly commit the entire working tree. I have developed a habit that I wouldn't feel comfortable if I haven't reviewed the chunks I am going to make into the commit.
- erik_seaberg 8y agoWhereas I don't feel comfortable with untested work, so "git checkout -p" (undo a change) and "git stash -p" (postpone a change) are how I get the workspace clean enough to commit.
- Rychard 8y agoWhile there are many people who don't understand git's staging area, there are far less that understand how to selectively stage/commit chunks, or even that such functionality is available at all. It should be a crime for people to blindly stage everything. Cleaning up after my colleagues easily falls under the "lost cause" umbrella.
- black-tea 8y agoMagit, for emacs, makes this workflow a joy. The "instant fixup/squash" features are great.