The Eight Git Commands That Cover Most Days

Most tutorials treat Git like a linear, polite conversation where you type a command, hit enter, and everything proceeds exactly as documented. But after twenty years of patching legacy payment gateways, I can tell you that Git is rarely polite. You’ll find yourself staring at a screen full of merge conflicts or realizing you just committed a secret key to a public repo, and that’s when the real learning begins. If you only study the “happy path,” you aren’t actually prepared for the job; you’re just waiting for the moment you feel completely lost. To survive a real production environment, you need to master the git commands you will use every day, not just the ones that work when everything is perfect.

In this post, I’m skipping the fluff and the “Hello World” workflows. I’ve selected five specific commands that form the backbone of my daily routine, specifically focusing on the moments where things tend to go sideways. You won’t just learn the syntax; you’ll learn how to use these tools to untangle a mess, undo a mistake, and regain control of your local environment when the terminal starts screaming at you.

Table of Contents

The Daily Bread: git add and git commit

The Daily Bread: git add and git commit.

Most tutorials treat these as a single, unified step toward progress, but in a production environment, they are where the mental friction begins. I always write my commit message before I even touch the code because if I can’t articulate the change in a single line, I probably don’t actually understand the logic I’m about to implement. It’s a small ritual that keeps my head clear when I’m staring at a messy diff.

Navigating the Flow: git pull and git fetch

We like to pretend we work in isolation, but backend development is a constant tug-of-war with everyone else’s changes. `git pull` is the command you’ll run a dozen times a day, but it’s also the one that introduces the most unpredictable chaos. It’s not just a way to get updates; it’s a way to invite everyone else’s mistakes into your local environment.

The Safety Net: git stash

The Safety Net: git stash for developers.

There is nothing quite as jarring as being mid-refactor on a complex database migration when a “critical hotfix” request lands in your Slack. You can’t switch branches because your current state is a broken, half-finished disaster that won’t even compile. This is where `git stash` becomes your best friend and worst enemy.

The Time Machine: git checkout and git switch

Moving between features and bug fixes requires a certain level of fluidity, and `git switch` (or the older `checkout`) is your primary vehicle. In my experience, the complexity arises when you realize you’ve been working on the wrong branch for the last three hours. It’s a sinking feeling in your stomach that every developer knows intimately.

The Undo Button: git reset

If the previous commands are about movement, `git reset` is about correction. It is the most powerful tool in your arsenal, and consequently, the most dangerous. When you realize you’ve just committed something that breaks the build, or you’ve accidentally deleted a file through a botched rebase, `reset` is how you claw your way back to sanity.

The Reality Check

Don’t trust a “successful” command blindly; always verify your state with `git status` before moving to the next step, because Git is very good at letting you commit exactly what you didn’t intend to.

Learning the commands is only half the battle; the real skill is knowing how to read the error messages when the “happy path” fails and your local history diverges from the remote.

Treat your commit messages as documentation for your future, tired self, because six months from now, you won’t remember why you bypassed the merge conflict instead of fixing it.

The Reality of the Workflow

A tutorial shows you a clean sequence of green checkmarks, but real development is just a series of small, tactical retreats and frantic reconciliations once you realize you’ve committed a secret key or tangled your merge conflicts into a knot that shouldn’t exist.

Pernille Askeland

The Reality of the Workflow

At the end of the day, these commands aren’t just syntax you memorize for a technical interview; they are your primary tools for navigating the inevitable chaos of a production environment. We’ve looked at how to move through your daily cycle, from the initial `git add` to the high-stakes moment of a `git rebase` or a frantic `git reset`. Most tutorials treat these as linear steps in a perfect, frictionless world. But as you’ve seen, the real work happens in the gaps—the moments when a merge conflict refuses to resolve itself or when you realize you’ve committed a secret to a public repo. Understanding the mechanics of failure is what actually separates a junior developer from someone who can sit calmly in a war room when the deployment goes sideways.

If you feel overwhelmed by the sheer number of flags and options, don’t worry. I spent my first few years in payment systems feeling like I was one wrong command away from deleting a decade of history. You will make mistakes. You will occasionally find yourself staring at a terminal that looks like it’s speaking a language you don’t understand. Just remember that Git is a time machine, and as long as you know how to navigate the logs, you can almost always find your way back to safety. Stop trying to master the happy path and start getting comfortable with the mess. That is where the real engineering begins.

Frequently Asked Questions

What happens if I realize I've committed a secret API key or a database password halfway through my local workflow?

First, stop. Don’t push. Once that secret hits a remote origin, it’s effectively public, even if you delete it in the next commit. Since you’re still local, use `git reset –soft HEAD~1`. This undoes the commit but keeps your changes staged. You can then scrub the secret from the file, add it to your `.gitignore`, and re-commit. It’s a clean fix, provided you haven’t already shared the disaster.

How do I handle a situation where a teammate's merge request breaks my local build, even though my code was fine ten minutes ago?

First, stop trying to fix your code. It’s not your code; it’s the state of your local environment. You’ve likely pulled a broken branch or a messy merge that’s polluted your workspace.

Is there a safe way to clean up a messy history of "fix typo" and "trying again" commits before I push to the main branch?

You want an interactive rebase. `git rebase -i HEAD~n` is your best friend here. It opens a list of your recent commits and lets you change “pick” to “squash” or “fixup.” I usually use “fixup” for those “typo” commits; it merges the changes into the previous commit and discards the useless message. It’s the only way to keep a history that actually tells a story instead of documenting your struggle.

About Pernille Askeland

I write the part the tutorial skipped: what it looks like when it breaks.

Scroll to Top