4 ms·
Great pointers. However, I have found that even though quite a few people know this, it takes special effort to enforce it. For example, the single-purpose comm
by Sourya 8y ago
Great pointers. However, I have found that even though quite a few people know this, it takes special effort to enforce it. For example, the single-purpose commits. My commits often tend to get a bit large, and include more than one "unit" of work, even though I know the best practices. Any pointers on how to avoid that?
- wodenokoto 8y agoIt is not ideal, but ... Get a GUI and pick out lines and files and multi-commit your changes.
- sanketsaurav 8y agoYMMV, but when I'm working on a feature branch that can take some time, I try to break it into pieces to merge into master often. One way to think about this is breaking away from the compulsion to commit the entire thing together in a branch. So I have `feat-x-part-1`, `feat-x-part-2` and so on. It's important to resist the urge to do push things only on perfection. It works for me.
- gglitch 8y agoI try to emphasize that commits should not be thought of as "save points," which seems to be a seductive way to think of them, but as "undo points."
- Sourya 8y agoThat is a good way to think. Thanks.
- WorldMaker 8y ago`git add --interactive` can be a great tool to learn in this case: https://git-scm.com/book/en/v2/Git-Tools-Interactive-Staging https://git-scm.com/book/en/v2/Git-Tools-Interactive-Staging In particular, the ability to only stage specific "hunks" at a time (interactive "patch" in the nomenclature of git) can make it possible to "untangle" multiple changes in your working directory into separate commits.
- Sourya 8y agoDidn't know about that. Thank you.