The life of a code change

Follow one commit from your laptop to a user's screen, step by step.

20 min read

You fix a bug in Cart.tsx. You type git push. An hour later, a shopper in another country sees the correct total.

Between those two moments, your change passes through five stops. In this lesson you follow it through each one.

Stop 1: a commit on your laptop

A is where the journey starts. Git gives each commit a unique ID, called a hash. Every later step uses that ID to name your change.

A commit is a small, named package of changes.

On your laptop, the change is safe but private. Nobody else can see it, and no robot checks it. The next step makes it public.

Stop 2: the pull request and the robots

You push the branch to GitHub and open a pull request. This starts . The robot gets a fresh, empty computer, copies your code onto it, and runs the checks your team chose.

.github/workflows/ci.yml
name: CI
on: pull_request
jobs:
check:
  runs-on: ubuntu-latest
  steps:
    - uses: actions/checkout@v4
    - uses: actions/setup-node@v4
      with:
        node-version: 22
    - run: npm ci
    - run: npm run lint
    - run: npm test
    - run: npm run build
  • on: pull_request starts the workflow for every pull request.
  • runs-on: ubuntu-latest asks GitHub for a clean Linux computer. It has none of your laptop's leftovers.
  • The last four lines install packages, lint, test and build. If one step fails, the pull request shows a red cross.
One failed check blocks the merge. Push a fix, and all the checks run again.

At the same time, Vercel builds a preview deployment. This is a full copy of the app with your change, on its own URL. Your reviewer clicks the link and tests the real page, not a screenshot.

A teammate reads the code and approves it. The rule is simple: robots check what a computer can check, and people check the rest.

Stop 3: merge, then build once

You merge the pull request. Now main has your commit, and the pipeline starts again on main.

This time, the build output is the thing that ships. Teams call it an .

For a Next.js app on Vercel, the artifact is the pages and functions that next build makes. For a team that uses containers, it is a Docker image with a tag like shop:a1b2c3d.

Two rules keep this step safe:

  1. Build once. The same artifact goes to every later step. Nobody builds again on a server.
  2. Never change an artifact. A new change makes a new artifact with a new name. Old ones stay on the shelf.

The second rule makes rollback easy, as you will see below.

Stop 4: deploy, a little at a time

To means to start the new artifact in production. Small sites switch all traffic at once. Large sites switch in steps, because a bug then reaches only a few users.

A gradual rollout. Each step waits until the graphs look healthy.

The first small group has a name: the .

Miners once took a canary bird into the mine. If the bird got sick, the miners left. In the same way, if errors go up on the canary, the rollout stops and the old version keeps serving everyone else.

Stop 5: users, and the way back

Now your fix is live. The team watches error rates and page speed for a few minutes after each deploy.

Tools like Datadog or Grafana draw these numbers as graphs. Chapter 8 covers them.

Sometimes a deploy goes wrong. The fastest fix is often not a new commit. It is a .

Because old artifacts never change, a rollback only points traffic back to the last good one.

A rollback moves the arrow. Nothing is built again.

The whole trip in one picture

  1. your laptop

    1. Git
      Commita1b2c3d on your laptop
  2. push

    every pull request

    1. GitHub
      Pull requeston GitHub
    2. GitHub Actions
      CI checkslint, test, build
    3. Vercel
      Previewa URL to review
  3. approved

    main

    1. Mergemain gets it
    2. Artifactbuilt once
  4. deploy

    production

    1. Canarya few users first
    2. healthy
      All usersfix is live
People act at two points: they write the commit and approve the pull request. Robots do the rest.
StopWho actsWhat comes out
CommitYouA hash, like a1b2c3d
Pull requestRobot and reviewerGreen checks, a preview
Merge and buildRobotOne artifact
DeployRobotNew version on servers
WatchTeam and dashboardsKeep it, or roll back
Remember4 points
  1. 01

    A change travels commit, pull request, merge and build, deploy, watch. Robots do most steps.

  2. 02

    CI runs your checks on a clean computer for every pull request, so "it works on my laptop" is not enough.

  3. 03

    The team builds once and never changes an artifact. The same files go everywhere.

  4. 04

    Large sites deploy to a canary first. Rollback points traffic back to the last good artifact.

Read more

Next, you see why the same app runs in three places: local, staging and production.