Supporting branches should have a short lifetime |
Supporting branches (feature, release and hotfix) are created for a specific task, such as implementing a feature, preparing a release or applying a hotfix to a bug. Because these are usually loosely associated with tasks, and tasks themselves usually should be achievable within a short period, branches should also only need to exist for as long as that task is being worked on. This is more of a guide rather than a hard rule, but once a task is complete and the related branch is no longer required, it should be deleted. |
3 | Stage and commit only the necessary files | When staging files before committing, you are presented with all the changes that you have made to your project. You should never click “stage all“ when staging files as there could have been a lot of random, unnecessary files that have changed in your working environment which may cause a conflict with other’s local versions of the project, especially if you had an outdated branch. An example: if you added a mesh and texture asset, created a material, created a prefab, and added it to a scene… but your git client (GitHub Desktop, Fork, Sourcetree, GitKraken or other) is showing “150 files changed”, in this case you should only stage the mesh, texture, material, prefab and scene files. |
4 | Small, frequent commits | This relates to rules 2 and 3. Just like the mantra “test early, test often“, the same should loosely apply to committing work on git. Whenever you make changes and something is in a working state, commit your work on your feature branch. This means that if you mess something up, you have a point to fall back to and restore a previous working version. This also gives a nice history to the work carried out so that you or other developers can easily track changes and find potential sources of future issues. An example: if you are working on a fully fledged save system, and have implemented data serialisation as the first step of creating the system - it’s time to commit the working, “work in progress“ state. |
5 | Prefabs over scenes | It’s much preferred to work on non-scene assets where possible. Obviously, scenes need to be worked on at some points, but if at all possible, changes should be made on dedicated, small assets rather than storing everything in a single scene asset. This approach will help reduce the number of conflicts. An example problem: some settings may need to be changed on a component attached to an object (e.g. camera move speed, or can be anything really). This component can be attached to a gameobject in a scene, and changing a value on it will result in the scene being edited. This means that if somebody else has also changed something in the scene (moved an object, changed a component value, added a new gameobject etc.) and both people push their work, there may be a conflict. A solution: if the component that needs changing actually lives in a prefab which is instantiated in the scene, changing the values will not result in the scene file changing, but instead the prefab file changing. It is a lot less likely that multiple people changed the same prefab rather than the same scene, thus averting the potential conflict. |
6 | Test your work in builds | Commonly, people will create their own test scenes and environments to test features or assets that they have been working on. They will test things in their isolated environments and assume that it’s all functional. They may then realise some time after that their addition is not in a build or not working in a build, this is because they didn’t do an integration test! It should be part of the standard workflow to test the auto-generated build when creating a pull request for their work to be merged into the main develop branch. It’s also healthy for development to get many people on the development team to test the latest builds frequently to help identify issues and bugs that need to be documented using the bug tracker. |