Skip to main content

Command Palette

Search for a command to run...

Why DevOps Engineers Use Git

Published
3 min readView as Markdown

As a DevOps engineer, Git is not only for application code.
You mainly use Git in two major areas:

  1. Infrastructure as Code (IaC)

  2. CI/CD and Build Automation


1. Git for Infrastructure as Code (IaC)

In DevOps, infrastructure is not managed manually.
Instead, it is defined using configuration files and scripts.
This approach is called Infrastructure as Code (IaC).

Example Scenario

  • Developers deploy applications to Kubernetes

  • You, as a DevOps engineer, manage:

    • Kubernetes YAML files (deployments, services, volumes)

    • Helm charts

    • Database configurations

In addition:

  • Your Kubernetes cluster may run on AWS

  • You manage AWS resources using:

    • Terraform (infrastructure provisioning)

    • Ansible (configuration and deployment)

  • You may also use:

    • Bash scripts

    • Python scripts

    • Automation scripts

All of these are files that change over time.


Why Git Is Needed Here

Git is used to:

  • Store all configuration files in one secure place

  • Track what changed, when, and by whom

  • Roll back to previous versions if something breaks

  • Avoid files being scattered on local machines


Team Collaboration

In real projects:

  • You rarely work alone

  • Multiple DevOps engineers manage the same infrastructure

So you need:

  • Collaboration

  • Version control

  • Conflict management

Git provides all of this.

👉 Same concept as developers working on application code, but here it is infrastructure code.


Key Idea

Infrastructure is written as code, and that code is stored and managed in Git.

This is the first major use case of Git for DevOps engineers.


2. Git for CI/CD and Build Automation

The second major use case is CI/CD pipelines and build automation tools (e.g., Jenkins, GitHub Actions, GitLab CI).


How CI/CD Works (High Level)

A typical pipeline does the following:

  1. Checkout application code from Git

  2. Run tests

  3. Build the application

  4. Deploy or package the application

Because of this:

  • CI/CD tools must integrate with Git repositories

DevOps Responsibilities Here

As a DevOps engineer, you may need to:

  • Configure integration between:

    • Git repository (GitHub, GitLab, Bitbucket)

    • CI/CD tool (Jenkins, GitHub Actions, etc.)

  • Understand how authentication and triggers work

  • Manage repository access and permissions


Git Commands in CI/CD Pipelines

Pipelines often use Git commands such as:

  • Get the latest commit hash

  • Compare changes between commits

  • Check which files or folders changed

    • Example: frontend vs backend
  • Decide:

    • Which tests to run

    • Which jobs to skip or execute

These Git operations help make pipelines faster and smarter.


Summary

Why DevOps Engineers Need Git

  1. Infrastructure as Code

    • Terraform, Ansible, Kubernetes, Helm, scripts

    • Version control, history, collaboration

  2. CI/CD and Build Automation

    • Integrate pipelines with Git repositories

    • Use Git commands inside pipelines

    • Control build and deployment logic


One-Line Summary

DevOps engineers use Git to manage infrastructure code and to power CI/CD automation workflows.

More from this blog

devops

22 posts