You must have a way to maintain version control for your code.
Version control means keeping track of changes to your code over time.
It allows you to:
- revert to an earlier version whenever you want to
- record your changes and the reasons why you made them, to help future developers understand the process
- work on changes in parallel as a team before merging them together
Making a commit means making a set of changes permanent. You should:
- write clear commit messages
- group changes according to their purpose
- review new changes
Writing commit messages
You should commit any changes with a clear message explaining the change. Clear commit messages help new or future developers and the public to see the changes you’ve made.
Your commit messages should:
- describe what you’ve changed and why
- link to any supporting information like development stories, bug reports, or third party documentation
For example, if the change is helping to fix a bug in a certain browser, your commit message could be:
Set cache headers
Browser-name was doing foo, so we need to do X.
See http://example.com/why-is-this-broken for more details.
When updating code, you should make small separate commits of changes and group the changes according to their purpose.
For example, if you make several commits in order to fix a bug, you should group those changes together.
Whenever possible, you should review each others’ code. The process for this could change between teams, but make sure:
- every code change is reviewed by someone who did not write it
- the process does not stop you from deploying software regularly or making quick bug fixes
Using distributed version control systems
You should use a distributed version control system so that:
- everyone involved in the process has a full copy of the code and its history
- it’s easier for developers to create ‘branches’ in their code to explore new features or approaches without encroaching on other work
- developers can continue to work when the network is unavailable, making small incremental commits, merging their changes back with everyone else’s at a later date
The Government Digital Service (GDS) and many other government teams use a distributed version control system called Git.
You can read:
Other uses for version control
You can also use version control in other parts of the work you’re doing to build your service.
For example, see how the World Wide Web Consortium (W3C) is using Git and GitHub to manage its specifications.
You may also find the Deploying software regularly guide useful.
Grouping changes and reviewing sub-sections added.
Guidance first published