← All articles
BlogMaths, Programming and MLOps

Version control for data science projects: best practices for high grades

Maths, Programming and MLOpsBy Sotiris Spyrou·Published 2026-07-30
Version control for data science projects: best practices for high grades

Version control for data science projects: best practices for high grades

Version control for data science projects requires tracking not just source code, but also large datasets, model weights, and the exact environment configurations used to produce specific results. The best practices involve using Git for source code alongside specialised tools like Data Version Control for large files, adopting experiment-driven branching strategies, and fixing random seeds to ensure total reproducibility.

In traditional software engineering, version control is mostly about managing lines of text. In machine learning, the system state depends on the code you wrote, the specific subset of data you trained on, and the hyperparameters you chose. If an examiner asks you to evaluate a version control strategy for an artificial intelligence project, they want to see that you understand this three-part dependency. You cannot simply say to use Git and commit often. You need to demonstrate how to handle gigabytes of training data, how to isolate experimental features without breaking the main production pipeline, and how to guarantee that a model trained on Tuesday can be perfectly recreated on Friday.

Managing code, data, and models separately

Standard version control systems like Git are designed for plain text files. When you attempt to commit a five-gigabyte CSV file or a folder of high-resolution training images into a Git repository, the system slows to a crawl and eventually fails. This happens because Git tries to track line-by-line changes, which is mathematically impractical for massive binary files or enormous tabular datasets. A strong exam answer will explicitly identify this limitation. You must explain that data and code have different lifecycles and require different tracking mechanisms.

To solve this problem, practitioners use a dual-tracking approach. You keep your Python scripts, Jupyter notebooks, and configuration files in Git. For the heavy assets, you use a dedicated tool like Data Version Control (DVC). This tool operates alongside Git. Instead of tracking the actual image files or model weights, the software computes a unique cryptographic hash for your data directory and creates a tiny text file containing that hash. You commit this small text file to Git, while the actual heavy data files are pushed to a remote storage bucket on a cloud provider.

Consider a worked example where you are training a convolutional neural network to classify medical X-rays. You start with a dataset of ten thousand images. You track this folder using your data versioning tool, generating a pointer file named data.dvc. You commit this pointer file to Git. Next week, your team receives two thousand new X-rays. You add them to the folder, run the tracking command again, and the system updates the hash in your pointer file. If the new data causes your model accuracy to collapse, you simply use Git to revert the pointer file to the previous commit. Your environment instantly syncs back to the exact ten thousand images you had last week.

Examiners frequently test this concept by presenting a scenario where a data scientist has lost track of which dataset produced which result. By explaining the separation of code and data using pointer files, you show a mature understanding of machine learning infrastructure. You move beyond basic programming knowledge and demonstrate systems thinking, which is exactly what university marking rubrics reward at the highest grade boundaries.

Structuring branches for machine learning experiments

In standard software development, branching strategies dictate that you create a new branch for a specific feature or bug fix, merge it into the main branch when complete, and then delete the feature branch. Machine learning requires a different approach. Data science is inherently exploratory. You might test ten different neural network architectures or hyperparameter combinations before finding one that works. Most of these branches will be dead ends, but their results remain highly valuable as a historical record of what you have already tried.

Instead of deleting experimental branches, best practice dictates treating branches as an immutable log of experiments. You might create a branch named after a random forest experiment and another named after a gradient boosting experiment. You run your training scripts, record the validation accuracy, and commit the final code and model pointers to that specific branch. Even if the gradient boosting model performs poorly, you keep the branch alive or tag the final commit. If your supervisor later asks why you did not use gradient boosting, you can instantly check out that branch and show them the exact code, data, and poor metrics.

A common pitfall in university projects is the single-branch workflow, where a student constantly overwrites their main branch with new hyperparameters. If the examiner asks you to critique a flawed workflow, look for this specific error. Overwriting the main branch destroys the baseline model. When you inevitably tune a parameter that degrades performance, you have no easy way to get back to your best-performing state. This poor practice frequently leads to panic right before a coursework deadline.

To structure this correctly, maintain a main branch that only contains the current best-performing, fully reproducible model. Treat your main branch as sacred. When you want to try increasing the learning rate, create a new branch specifically for that test. Run the training pipeline. If the model achieves a higher metric than the baseline, you merge the experimental branch into main. This ensures your primary branch always reflects the highest standard for your specific project, while your history provides a clear audit trail of your scientific process.

Guaranteeing reproducibility through environment tracking

Code and data are only two pieces of the reproducibility puzzle. The third piece is the computational environment. A script that runs perfectly on your laptop might crash on the university server, or it might silently produce different mathematical results because the server uses a different version of a linear algebra library. Examiners love to set questions around dependency conflicts and irreproducible results. Your answer must address how to version-control the environment itself.

At a minimum, best practice requires tracking exact package versions. In Python, this means avoiding a vague requirements text file that simply lists the names of your libraries. Instead, you must specify the exact version numbers. A more professional approach involves using virtual environment managers that generate detailed lock files. These lock files record the exact versions of your primary packages as well as all their underlying dependencies, ensuring that anyone who clones your repository will install the identical software stack.

For true isolation, containerisation tools take environment versioning a step further. A Dockerfile is a script that defines an entire operating system setup, including the Python version, system libraries, and environment variables. By committing the Dockerfile to your Git repository, you are effectively version-controlling the computer itself. If an exam question asks for the most rigorous way to ensure a model can be deployed reliably to production, containerisation is the correct technical answer to provide.

Finally, environment tracking also encompasses the random number generators used in machine learning algorithms. Neural network weight initialization, train-test splits, and data shuffling all rely on randomness. If you do not explicitly set and record the random seed, your code will produce a different model every time it runs. Setting the random seed should be treated as a strict configuration parameter that is committed to version control alongside your learning rates and batch sizes.

How to answer this in an exam

When faced with an exam question about version control in data science, mark schemes heavily reward the distinction between traditional software engineering and machine learning. Do not just write a generic list of Git commands. Start by explicitly stating that machine learning projects consist of code, data, environment, and model weights, and that each dimension requires a specific tracking strategy.

If asked to design a workflow, draw out a clear pipeline in your answer booklet. State that you would use Git for source code and a specialised tool for large datasets. Specify that you would enforce a branching strategy where the main branch holds the best model and separate branches track individual experiments. Mention that you would secure reproducibility by versioning dependencies with a lock file and fixing random seeds. This comprehensive approach shows the examiner that you understand the practical realities of deploying artificial intelligence systems.

The Full Marks Press Programming for AI guide covers this topic extensively, walking you through several worked exam questions on project architecture and deployment pipelines. It breaks down exactly how to structure your answers to pick up maximum marks in scenario-based questions. Practising these scenarios is the best way to prepare for the long-answer sections of your paper.

Frequently asked questions

How should I version control Jupyter Notebooks? Jupyter Notebooks store code, output, and metadata in a single JSON file, making Git diffs incredibly messy. Best practice is to strip the outputs before committing using command-line stripping tools, or to convert the notebooks to pure Python scripts for production tracking while keeping the notebooks strictly for exploratory work.

What happens if I accidentally commit a large dataset to Git? If you commit a massive file, it gets baked into your Git history, slowing down all future repository operations even if you delete the file in a subsequent commit.

Revising this for an exam? The Full Marks Press guides cover it with worked exam questions and mark schemes. Get a free copy.

ShareXLinkedInWhatsApp
Sotiris Spyrou

Practitioner and author at Full Marks Press, a Verity AI imprint.