Fixing a bug while working on a different part of the code base
- by imgx64
This happened at least once to me. I'm working on some part of the code base and find a small bug in a different part, and the bug stops me from completing what I'm currently trying to do. Fixing the bug could be as simple as changing a single statement.
What do you do in that situation?
Fix the bug and commit it together with your current work
Save your current work elsewhere, fix the bug in a separate commit, then continue your work [1]
Continue what you're supposed to do, commit the code (even if it breaks the build fails some tests), then fix the bug (and the build make tests pass) in a separate commit
[1] In practice, this would mean: clone the original repository elsewhere, fix the bug, commit/push the changes, pull the commit to the repository you're working on, merge the changes, and continue your work.
Edit: I changed number three to reflect what I really meant.