Git: The Time Machine Every Developer Deserves
Git is the most powerful tool most developers only half-understand. Here's a love letter to version control and what it can actually do.
Git: The Time Machine Every Developer Deserves
There is a moment in every developer's career when they delete something important. Maybe it's a file. Maybe it's a directory. Maybe it's — and I say this from experience — an entire database table, in production, because a migration script had a typo.
If you are using Git correctly, this moment is merely embarrassing. If you are not, it is catastrophic.
Git is the most powerful tool in the average developer's toolkit, and also the most casually misused. Most people learn four commands — add, commit, push, pull — and treat the rest of the manual as advanced topics for people who enjoy pain. This is understandable. Git's interface is notoriously unintuitive. The error messages read like they were written by someone who found other error messages too friendly.
But under that interface is a genuinely beautiful idea, and learning it properly is one of the highest-leverage things you can do for your career.
The Core Idea: Snapshots in Time
Git doesn't store changes — it stores snapshots. Every commit is a complete picture of what your project looked like at that moment, plus a pointer to its parent. The history of your repository is a linked list of complete states, going all the way back to the first commit.
This matters because it means you can always go back. Not to a patch, not to an approximation, but to the exact state of every file at any point in the history. git checkout abc1234 and your working directory becomes the past. Your codebase becomes a time machine.
git bisect makes this practical for debugging. You tell Git: this commit is good, this commit is bad. Git performs a binary search through your history, checking out commits halfway between the two extremes and asking you to mark each as good or bad. In ten steps, it finds the exact commit that introduced the problem. Among thousands of commits. In seconds.
This only works if your commits are atomic — small, focused, complete thoughts, each one a working state. A commit message of "various fixes" and a diff of 47 files is technically a snapshot, but it's a useless one for time-travel purposes.
Branch Fearlessly
One of the fundamental shifts in working with Git well is understanding that branches are cheap. Creating a branch takes less than a millisecond. Deleting one takes less than a millisecond. The cost of a branch is essentially zero.
This means you should branch constantly. Branches are how you experiment without fear. Want to try a different approach? Branch. Halfway through a feature when an urgent fix comes in? Branch for the fix, come back to the feature. Exploring an architectural change you're not sure about? Branch, experiment, merge or discard.
Developers who don't branch freely are developers who make risky changes directly to main, who have half-finished work mixing with finished work, who can't switch context quickly. The branch is the answer to most of these problems.
The corollary: merge often. A branch that lives for three weeks diverges so far from main that merging becomes archaeology. Short-lived branches — a day, maybe three days — merge cleanly and keep the team in sync.
Writing Commit Messages Like You Mean It
Here is an experiment: open your repository and run git log --oneline. Read the messages. Now imagine you're six months in the future, debugging a regression, and you need to understand what changed and why.
"fix bug" tells you nothing. "update stuff" is noise. "WIP" is an admission that you didn't finish but committed anyway and then forgot to come back.
A useful commit message has two parts: a short subject line (50 characters, imperative mood — "Add user authentication", not "Added" or "Adding") and, when needed, a body that explains why the change was made, not what it does. The diff shows you what changed. The commit message explains the reasoning that a diff can't capture.
AI tools are genuinely useful here. Paste your diff and ask for a commit message. The result is usually at least as good as what most developers write themselves, and often better — because it's reading the actual changes, not the story in your head.
The Commands Worth Learning
Beyond the basics, a few commands radically improve quality of life:
git stash lets you shelve work-in-progress without committing. Mid-task, urgent thing comes up, you're not ready to commit — stash it, deal with the urgent thing, pop the stash and continue. This should be second nature.
git log --graph --oneline --decorate shows the branch history visually. Once you understand what the graph is showing, the repository's history becomes readable. Most GUI tools show you this, but knowing the command means you're not dependent on one.
git rebase -i (interactive rebase) lets you rewrite history before you share it. Squash ten "WIP" commits into one meaningful one. Reorder commits. Split a commit that did too many things. The history you push should be the history you want — clear, logical, readable. Interactive rebase is how you get there.
And git reflog — the safety net of safety nets. Even if you've done something seemingly catastrophic — deleted a branch, made a "hard" reset — the reflog has a record of every recent change to HEAD. In most cases, what seems lost is recoverable. Git is a time machine in both directions.
The Cultural Side
Git isn't just a technical tool — it's a coordination mechanism. The way a team uses Git reflects and shapes the way they work together.
Small commits, clear messages, and short-lived branches are signals of a team that communicates well, thinks clearly about what they're building, and respects the people who will read their history later. The discipline of writing a good commit message is the discipline of articulating what you did and why — which is also the discipline of thinking clearly.
Code review is made better by readable commits. Blame (now called "annotate" in polite company) is only useful if the commits it points to explain themselves. The history of a well-maintained repository is a narrative — not just of what was built, but of why it was built that way.
Learn Git properly. Not just the four commands. The model, the mental picture, the power commands. It is one of those investments that pays back every single day, for the rest of your career.
And next time you delete something important, you will be grateful you did.
Jako Heiberg
Software developer with 40+ years of building things that work. Full-stack, FastAPI, React. Based in Cape Town, working remotely, worldwide.