Commits are history. Branches are collaboration. But delivery is the endgame. Code isn’t useful until it runs in production. This is where CI/CD—Continuous Integration and Continuous Delivery—meets Git. Every push, every merge, every tag can trigger automated pipelines that test, build, and deploy. In this chapter, we’ll explore how Git integrates with CI/CD to turn history into living software.


The Idea of CI/CD

  • Continuous Integration (CI): Automatically test and integrate changes frequently.
  • Continuous Delivery (CD): Automatically prepare and deploy builds to staging/production.

Git provides the events. CI/CD systems provide the automation. Together, they create a seamless loop from commit to deployment.

Visualization:

flowchart LR
  Dev[Developer commit] --> Repo[Git Repository]
  Repo --> CI[CI Pipeline: build & test]
  CI --> CD[CD Pipeline: deploy]
  CD --> Users[Running Software]

Common CI/CD Systems

  • GitHub Actions (GitHub-native).
  • GitLab CI/CD (deeply integrated).
  • Jenkins (classic, flexible).
  • CircleCI, Travis CI, Azure Pipelines—cloud options.

All integrate tightly with Git via webhooks and triggers.


Triggering Pipelines with Git Events

Typical Git events that trigger CI/CD:

  • push: run tests on new commits.
  • pull request / merge request: run tests before merging.
  • tag: build and deploy releases.

Example GitHub Actions workflow (.github/workflows/ci.yml):

name: CI
on: [push, pull_request]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Install deps
        run: npm install
      - name: Run tests
        run: npm test

Semantic Versioning + CI/CD

When you push a tag like v1.2.0, pipelines can automatically build release artifacts, upload to registries, and deploy.

Visualization:

flowchart TD
  Tag[Push tag v1.2.0] --> CI[CI Build Release]
  CI --> Publish[Publish to Registry]
  CI --> Deploy[Deploy to Production]

Solo Workflow Example

As a solo dev, you push to GitHub. GitHub Actions runs your tests automatically. If green, your code deploys to Netlify. You focus on coding, not pipelines.


Team Workflow Example

On a team, every merge request runs CI. Tests ensure quality before merging. Tags trigger deployments to production. Nobody deploys manually anymore—the pipeline is the deployer.

Visualization:

flowchart LR
  Devs[Team commits & PRs] --> Repo[Git]
  Repo --> CI[CI checks: tests, lint]
  CI --> Merge[Merge only if green]
  Merge --> Deploy[Auto deploy to prod]

Best Practices

  • Keep pipelines fast (<10 min ideal).
  • Run tests in parallel.
  • Automate rollback.
  • Secure secrets in pipeline configs.
  • Treat pipelines as code (ci.yml versioned).

Think Different Mindset

CI/CD turns history into living reality. Git alone is memory; CI/CD is action. Every commit becomes a heartbeat that pulses into the real world. This mindset teaches that development isn’t just writing—it’s delivering. The value isn’t in commits alone, but in their deployment.


Git and CI/CD are inseparable partners. Commits trigger pipelines, tags trigger releases, branches trigger environments. Together they ensure code moves swiftly and safely from idea to users. In the next chapter, we’ll cover troubleshooting—what to do when Git itself seems to betray you, and how to recover using reflog and other tricks.