2014-07-02

6 Steps to Better Commits

While working on my multi-platform game engine, here's some things I have learned:

1. Run all unit tests or functionality tests before submitting.
Should be a no-brainer, but laziness can lead to less testing and more bugs. Especially bad if you make many submits without testing because by then your search-space has grown needlessly. If you don't have any tests, stop reading this and write them now.

2. Submit only related changes.
For example, if you are hunting down a bug and inspect a changelist with a message "Fixed texture loading" and the changelist also contains modifications to Audio.cpp, finding the bug takes more time.

3. Fix bugs before adding new features.
Worst-case scenario would be when a new feature depends on a bug in an older feature and when the bug is finally fixed, the new feature stops working.

4. Describe all the changes you did in the commit message.
If you browse through a commit log of a source file and find a commit with a message that has nothing to do with that file, you have not documented your commit well and it could be hard to reason about why the file was changed.

5. Diff all the changes to be submitted for sanity-check.
Sometimes you have been making ad-hoc changes to test/debug a feature but forgot to revert them before submitting.

6. Try to submit a whole, working new feature in one submit instead of many non-working submits.
If the feature is really big, you can split it into smaller submits if each of the smaller submits represents a logical unit that can work without other submits.

No comments: