• Formerly Platform.sh
  • Contact us
  • Docs
  • Login
Watch a demoFree trial
Blog
Blog
BlogProductCase studiesNewsInsights
Blog

Git-driven environments: why treating infra as code unlocks consistent builds every time

GitIaCGitOpspreview environments
08 February 2026
Jack Creighton
Jack Creighton
Senior Product Marketing Manager
Share

At some point in every developer's journey, they have experienced a “but it works perfectly in staging”. Then the code merges to production, and something breaks. Could be a missing environment variable or a service version mismatch, a configuration that drifted in the environment without anyone noticing. These reasons could go on and on. 

Then the post-deployment scramble begins. You dig through dashboards, compare settings, and try to reconstruct what actually runs in production versus what you tested. Hours later, you find the culprit: someone changed a setting in staging three weeks ago but never documented it.

This is the cost of managing infrastructure outside your codebase. And it compounds with every team member, every branch, and every deploy.

Git-driven environments solve this by putting your full infrastructure definition: apps, services, routes, and build logic into version-controlled code. Every branch becomes a deployable, production-aligned environment.

The real reason builds are inconsistent

Environment drift happens when dev, staging, and production fall out of sync. It's rarely one big mistake. It's dozens of small ones:

  • Someone updates a database version in staging through a dashboard but forgets to do the same in dev.
  • A build command gets tweaked in production. The change never reaches the repo.
  • A new team member spins up a local environment using outdated setup docs.

Each change is invisible. There's no commit, no pull request, no audit trail. Over time, your environments diverge silently until something that worked everywhere else breaks in production.

The cost isn't theoretical. For many organizations, requesting new space for an application means submitting multiple tickets to multiple teams and waiting one to two weeks. Upgrading a runtime or service version can stretch into months. Before any product work even starts, teams commonly spend an entire sprint, ten days of full-team effort, just standing up infrastructure and CI pipelines. That's feature development time lost before a single line of product code ships

How Git-workflow changes everything

Git-driven infrastructure treats your repository as the authoritative source for how your application runs. Every environment configuration lives in version control alongside your code. When you push a branch, the platform reads your configuration file and provisions everything needed to run that exact version of your application.

This approach delivers concrete benefits. 

First, environment parity becomes automatic. The same configuration file deploys to development, staging, and production. Environment-specific differences get handled through variables, not different configurations. 

Second, infrastructure changes go through code review. Modifying infrastructure means editing files and creating pull requests. Your team reviews infrastructure changes with the same rigor as application changes. 

Third, rollback becomes trivial. Deployments are deterministic processes based on Git commits. Rolling back infrastructure changes is as simple as reverting commits.

The configuration file also serves as documentation that stays current. When everything lives in code, there is no gap between what the documentation says and what actually runs.

Every git branch becomes a live environment

With Git-driven workflows, creating a preview environment becomes a single action: push a branch. The platform automatically provisions an isolated environment that inherits data and services from its parent. Databases, network storage, queues, and routing configurations all replicate automatically.

This changes how teams work. Developers can test risky migrations against cloned production data without touching the live environment. Content editors can verify changes in preview URLs while developers refine API logic. QA can run end-to-end tests in environments that mirror production exactly.

When the experiment finishes, deleting the branch automatically tears down the environment. No cleanup tickets. No orphaned resources. No forgotten infrastructure accumulating cost.

Obscure, data-dependent bugs reproduce instantly when your preview environment carries real data and assets. Environment drift disappears from the conversation because every branch clones from its parent by default. Parity is not an afterthought; it is the starting point.

Scaling without the complexity tax

Manually managed Terraform and Kubernetes stacks introduce hidden coupling and fragility that teams often underestimate. Version upgrades require learning new syntax. Configuration files from years ago may no longer work with current tooling. The complexity compounds as team size grows and more people touch the infrastructure.

Git-driven platforms reduce the number of decisions developers need to make. Infrastructure configurations that would otherwise require separate Terraform files, Kubernetes manifests, and CI/CD pipeline definitions are collapsed into a single declarative file. The platform validates syntax on push and shows errors in build logs before misconfiguration reaches reviewers.

When managing environments at scale, knowing that every environment built from the same branch is identical eliminates entire categories of debugging sessions. Configuration drift between environments becomes impossible. Once functionality is verified in one environment, it functions identically across all environments running that configuration.

How Upsun implements Git-driven environments

Upsun treats your Git repository as the single source of truth for both application code and infrastructure. A unified .upsun/config.yaml file defines your runtime, services, routes, and environment variables. That configuration travels with your code, which eliminates the disconnect between what works locally and what runs in production.

Each push spins up an isolated container stack. You can branch that stack, data included, into a new preview environment in under a minute. The CLI and API enable teams to automate integration with existing CI/CD workflows without retooling everything.

Source integrations with GitHub, GitLab, and Bitbucket mean environments can be created automatically for pull requests and branches. When a merge request opens, an environment spins up with the target branch as its parent and a copy of its parent's data. Merge the request, and the preview environment tears down automatically.

Read-only infrastructure guarantees reproducibility. Files cannot be modified at runtime, so when you merge code from staging to production, you deploy the identical filesystem image. There is no configuration drift, no manual modifications, and no discrepancies between what passed testing and what runs live.

Moving forward

Infrastructure should be a dependency of your application, just like any other dependency. Beyond the contract between application code and a service, developers should not need to worry about how that service gets provisioned or configured.

Git-driven environments make this practical. Every branch becomes a deployable environment. Every configuration change goes through review. Every deployment is reproducible from the version control system.

The result is faster feedback loops, fewer post-deployment surprises, and more time spent building features instead of debugging environment inconsistencies.

Ready to eliminate configuration drift? Start a free Upsun trial and experience Git-driven deployment.

Stay updated

Subscribe to our monthly newsletter for the latest updates and news.

Your greatest work
is just on the horizon

Free trial
UpsunFormerly Platform.sh

Join our monthly newsletter

Compliant and validated

ISO/IEC 27001SOC 2 Type 2PCI L1HIPAATX-RAMP
© 2026 Upsun. All rights reserved.