Keeping track of changes to anything - code, a file, multiple files - can be tricky, often resulting in many copies of the same thing.
On this page, we look at what version control is and some resources for getting started using version control systems with your code (and files, webpages, etc).
Version control systems record changes to a file or set of files, allowing you to store the differences (often referred to as "diffs") between those files in order to keep track of changes, see the history of a file, and roll back to previous versions. This makes it a lot easier to iteratively work on something and stay on top of changes, bugs, and what has happened over time.
Version control also makes collaboration easier, making it possible to merge changes by different people, work on different features, and keep track of who made which changes.
For a more illustrated example of version control, see Software Carpentry's page on Automated Version Control.
For an introduction to version control, see the University's Research Coding Club's page for their introduction to version control session. If you come along to our live training session on an introduction to version control, this is the same material!
There are also a whole load of different resources online relating to version control. Be critical and explore different resources to see what might suit you.
One recommendation is to try out the Version Control with Git materials from Software Carpentry. You might find it useful to look through their Unix Shell materials first if you're new to the command line.
As well as version control, if you are writing software to generate, process, and/or analyse your research data, you will want to consider how you manage, archive and share this code. Planning what you will do with any research software from the start of your project will help you with this and ensure that you know how you will be able to share your software if needed for others to reproduce your methodology or verify findings. For information about this, see the research data management page on software and computer code:
Take a look at the resources on this page to get started using version control, using their setup guidance and explanations.
Then, start using version control with your code! Try making changes and see what happens.