After writing some product code which is serving hundreds of millions of people everyday, I have realized that these industry coding practices are also very useful for most research projects. Below are some most important tips I have been using for my research projects based on revision control via GitHub.
Using Pull Requests (PRs)
- Always develop on your own development branches and create pull requests to push changes into the master/release branch, even if you are the only one who writes code for the project.
- When to create a PR? In most cases, each PR should contain a small group of commits that have reached a certain milestone, such as adding a new algorithmic component or fixing a serious bug.
- What to write in a PR? In each PR, provide some brief information about the background/context and the changes. Add some experimental results if possible. See a simple example here.
- When to merge a PR? A PR is ready to be merged when the PR has been approved by reviewers, the changes have been verified via experiments, and/or the code has passed build test.
- How to merge a PR? When merge a PR, use the “Squash and merge” option to keep a clean history of commits in the base branch.
Some Additional Notes
- Do not put large data assets such as image sequences or videos under git. Use Git LFS if necessary.
- Do not merge temporary code (e.g., for debug purpose) into the master branch.
- Open issues to track major bugs and to-do items.
- Commit frequently just in case…
My de facto PhD supervisor, Dr. Li-Yi Wei, has also written a blog post on the same topic with many useful tips.