Every DevOps workflow starts with code in version control: application code, Dockerfiles, Kubernetes manifests, Terraform, CI pipelines, even documentation. If it is not in Git, it does not exist as far as automation is concerned. This lesson explains what version control solves, why Git won, and the handful of ideas the rest of the course builds on.
In simple words
- Version control: a system that records every change to your files, so you can see who changed what, go back in time, and work in a team without overwriting each other.
- Git: the most popular version control tool. Every copy holds the full history, so it works offline and is very fast.
- Repository (repo): a project folder whose history Git tracks.
- Commit: a saved snapshot of your project at one moment, with a message saying what changed.
The problem
Without version control, teams end up with folders like this:
deploy.shdeploy_old.shdeploy_final.shdeploy_final_v2_LEELA.shdeploy_final_v2_LEELA_fixed.shQuestions that should be easy become impossible:
- Which file is the current one?
- What changed between yesterday and today, and why?
- Who changed the database password line, and when?
- The site broke after the last deploy. What exactly did we deploy, and how do we go back?
- Two people edited the same file. Whose version wins?
What version control gives you
A version control system (VCS) records the history of a set of files as a series of snapshots, each with an author, a time and a message explaining why. It lets you:
- See history: every change, who made it and why.
- Compare any two versions line by line.
- Go back to any earlier state, for one file or the whole project.
- Work in parallel on separate branches without stepping on each other.
- Merge parallel work back together, with help when changes collide.
- Collaborate through a shared server that everyone pushes to and pulls from.
- Automate: CI/CD pipelines start when commits arrive.
Why Git
There have been many version control systems (CVS, Subversion, Perforce, Mercurial). Git, created by Linus Torvalds in 2005 for the Linux kernel, became the standard. Today almost every company and open-source project uses it, hosted on platforms such as GitLab, GitHub and Bitbucket.
What makes Git different:
- Distributed. Every clone is a full copy of the repository with its entire history. You can commit, branch, view history and compare versions offline. There is no single point of failure.
- Fast and cheap branching. A branch is just a pointer, so creating one is instant. That encourages working on small, isolated changes.
- Snapshots, not differences. Each commit records the full state of the project (efficiently, by reusing unchanged files), which makes switching versions fast and reliable.
- Integrity. Every object is named by a cryptographic hash of its content, so history cannot be silently corrupted or altered.
The key ideas, in one picture
working tree --git add--> staging area --git commit--> local repository --git push--> remote (GitLab) (files you edit) (next commit) (history in .git) (shared copy)- Repository (repo): the project plus its full history, stored in a hidden
.gitfolder. - Commit: a snapshot of the project at one moment, with a message and an author. Each commit points to the one before it, forming the history.
- Working tree: the files you see and edit.
- Staging area (index): where you prepare exactly what goes into the next commit.
- Branch: a named line of development; technically a pointer to a commit.
- Remote: another copy of the repository, usually on a server, that you exchange commits with.
Try your first Git command in the practice terminal. You will set Git up properly in the next lesson:
git --versiongit helpGit in DevOps
Version control is the foundation of almost everything else in this course:
| Practice | How it depends on Git |
|---|---|
| CI/CD | Pipelines run on every push and merge request |
| Infrastructure as Code | Terraform and Ansible changes are reviewed and versioned like code |
| GitOps | Argo CD deploys whatever is in a Git repository to Kubernetes |
| Code review | Merge requests show diffs and collect approvals |
| Auditing | History shows who changed what, when and why |
| Incident response | git log, git diff and git revert find and undo bad changes fast |
Real-world scenario: the 2 a.m. rollback
A configuration change takes down a payment service late at night. Because the configuration lives in Git, the on-call engineer runs git log on the config repository, sees the last change ("Increase DB pool size to 500"), reads the diff, and runs git revert on that commit. The pipeline redeploys the previous configuration in four minutes. Without version control, the team would have been comparing files by hand, guessing what changed.
Common misconceptions
- "Git is GitHub." Git is the tool on your computer. GitLab and GitHub are services that host Git repositories and add collaboration features.
- "Version control is only for developers." Ops engineers version scripts, configs, dashboards and infrastructure definitions.
- "A backup is the same thing." Backups copy files; Git records why each change was made and lets you combine parallel work.
- "Commit is the same as save." Saving writes a file; a commit records a deliberate, described snapshot of the project.
Practice
- List five files or folders from your own work that should be in version control, and one that should not (hint: secrets).
- Run
git --versionin the practice terminal. - Write down three questions about a past incident that history in Git would have answered.
Cheat sheet
repository project + full history (.git folder)commit described snapshot of the projectworking tree the files you editstaging area what goes into the next commitbranch movable pointer to a commitremote another copy, usually on GitLab/GitHubgit --version check Git is installedKey takeaways
- Version control records every change with an author, a time and a reason, and lets you compare and restore any version.
- Git is distributed: every clone has the full history and works offline.
- Changes flow from the working tree to the staging area, to commits in the local repository, and then to a shared remote.
- CI/CD, Infrastructure as Code and GitOps all start with Git.