5 Git commands that save ML experiments

Beyond add, commit, push: the recovery and inspection commands I reach for when experiments get messy.

Git MLOps Reproducibility Experiment Recovery
Five Git commands that save ML experiments beyond add, commit, push: git stash push, git show --stat HEAD, git diff HEAD~1 HEAD, git restore, git reflog with a caution about rewriting shared history and Git not being a data lake

TL;DR: Version control is not bureaucracy. It is a recovery system for work that rarely goes exactly as planned. Learn the recovery commands — they are the ones you actually reach for when experiments break.

The Problem

Most data scientists learn enough Git to survive: git add, git commit, git push. But ML work is rarely linear. You change several files, start a run, spot an issue, switch priorities, break a script, or realise the last commit contains something that should not be there. In those moments the basic trio is not enough.

Experiments get messy, and recovery matters as much as recording history.

The Approach

These are the Git commands I reach for most often when things go sideways:

git stash push -m "wip: experiment"

Save unfinished local work before switching tasks without making a partial commit.

git show --stat HEAD

Inspect exactly what the latest commit contains at a glance.

git diff HEAD~1 HEAD

Compare the latest commit with its parent to review the exact change before sharing or deploying.

git restore path/to/file

Restore a single uncommitted file without resetting the entire working tree.

git reflog

Find previous local HEAD positions when you need to recover work after a reset, rebase, or lost branch reference.

git rebase -i is useful for cleaning local commits before review, but avoid rewriting history that collaborators already depend on.

Outcome

Git is not just code storage — it is part of experiment recovery, review, and reproducibility. But it has limits. Use Git LFS, DVC, object storage, or your organisation's approved tooling for large datasets and model artefacts. Do not treat a normal Git repository as a data lake.

Key Takeaway

Design insight: Version control is not bureaucracy. It is a recovery system for work that rarely goes exactly as planned. Learn the recovery commands — they are the ones you actually reach for when experiments break.

FAQ

What is the key takeaway from "5 Git Commands That Save ML Experiments"?

Version control is not bureaucracy. It is a recovery system for work that rarely goes exactly as planned. Learn the recovery commands — they are the ones you actually reach for when experiments break.

Who wrote this and what is it about?

This was written by Mahmoud Trigui, Senior Data Scientist. Git commands that save ML experiments: stash, show, diff, restore, and reflog for recovery and reproducibility in messy workflows.

Comments

ForecastingTime SeriesMachine LearningPredictive ModelingFeature EngineeringNLPLLM ApplicationsDocument AICustomer SegmentationTelecom AnalyticsAnomaly DetectionRecommendation SystemsGraph AnalyticsGeospatial AnalyticsStatistical AnalysisExperimentation & A/B TestingPythonRSQLDataikuShiny DashboardsStreamlit AppsData VisualizationProduction MLModel EvaluationDecision SystemsData AutomationBusiness Analytics