Lesson 01 beginner

Introduction to Git

What Git is, the problems version control solves, how Git records history as snapshots, centralized versus distributed systems, where Git shows up in DevOps work and what changed in Git up to version 2.56.

Git is a version control system: a tool that remembers every saved state of a project, who made each change, when and why. Instead of keeping only the latest copy of your files, Git keeps the whole story, and lets you jump to any chapter, compare two chapters or write two different endings at the same time and pick one later.

It was written by Linus Torvalds in 2005 to manage the Linux kernel, a project with thousands of contributors. Today it is the default for almost all software, and for most of what DevOps engineers write too: pipelines, Terraform, Kubernetes manifests, Ansible playbooks and shell scripts.

Life without version control

Picture the Orbit team before they used Git. The project lived in a shared folder:

  • Files named like a ransom note. deploy.sh, deploy-new.sh, deploy-new-FINAL.sh, deploy-jeff-fixed.sh. Nobody is sure which one production runs.
  • Silent overwrites. Two people edit config.yaml on the same afternoon. The last one to save wins and the other change is simply gone.
  • “It worked yesterday.” The API breaks after a release. Somebody changed something, but there is no record of what, so the hunt takes hours.
  • Rollback by memory. Going back to last week’s version means hoping someone kept a copy.
  • No review. Changes go live without a second pair of eyes because there is no easy way to show what changed.

Git solves all five with one idea: every time you reach a meaningful point, you save a commit, a labelled snapshot of the project. Commits form a history you can read, compare, search and restore from.

What a commit really is

A commit is a snapshot of the whole project at one moment, plus some facts about it:

Part of a commitExample
ID (hash)3f9c2e1 (short form of a 40-character SHA-1 hash)
Author and dateAna Souza <ana@orbit.dev>, 2026-11-06 10:14
MessageAdd health check endpoint to the API
ParentThe commit that came before it
SnapshotEvery tracked file, as it was at that moment

The ID is computed from the content. Change one byte anywhere and the hash changes, which is why Git history is very hard to tamper with silently. Because each commit points to its parent, the commits form a chain you can walk back to the very first one.

Here is how the first two checkpoints of Orbit look. Do not worry about the commands yet: lesson 3 explains each of them.

$ git init orbit
Initialized empty Git repository in /home/ana/orbit/.git/
$ cd orbit
$ echo "console.log('Orbit API starting');" > server.js
$ git add server.js
$ git commit -m "Create API entry point"
[main (root-commit) 3f9c2e1] Create API entry point
 1 file changed, 1 insertion(+)
$ echo "console.log('Orbit API listening on 8080');" > server.js
$ git commit -am "Log the listening port at startup"
[main 8a41d07] Log the listening port at startup
 1 file changed, 1 insertion(+), 1 deletion(-)
$ git log --oneline
8a41d07 (HEAD -> main) Log the listening port at startup
3f9c2e1 Create API entry point

And when something breaks, the history answers the question “what changed?”:

$ git diff 3f9c2e1 8a41d07 -- server.js
-console.log('Orbit API starting');
+console.log('Orbit API listening on 8080');

Tip: Git does not store a full copy of every file in every commit. Files that did not change are shared between snapshots, and Git compresses similar files together. A repository with years of history is often smaller than you would guess.

Centralized versus distributed

Older tools such as Subversion (SVN) and CVS are centralized: one server holds the history, and your computer holds only a working copy. Git, like Mercurial, is distributed: every clone holds the complete history.

Centralized (SVN, CVS)Distributed (Git, Mercurial)
Where history livesOnly on the central serverIn every clone
Commit without networkNoYes
View old versions offlineNoYes
If the server diesHistory may be lostAny clone can restore it
BranchingHeavy, often avoidedCheap, used all day

Distributed does not mean “no server”. Teams still agree on one shared copy, usually on GitHub, GitLab or Bitbucket, and treat it as the source of truth. The difference is that your laptop is a full peer: you can commit on a plane, browse five years of history in a basement and recover the team’s repository from any developer’s clone.

Note: Git and GitHub are not the same thing. Git is the tool on your machine. GitHub, GitLab and Bitbucket are services that host Git repositories and add pull requests, issues, CI pipelines and permissions on top.

Where Git shows up in DevOps

For a DevOps engineer, Git is not only where application code lives. It is where the platform lives:

  • Pipelines: .gitlab-ci.yml, GitHub Actions workflows and Jenkinsfiles are versioned next to the code they build.
  • Infrastructure as code: Terraform modules and their variables (see the Terraform Tutorial).
  • Kubernetes manifests and Helm charts: in GitOps, tools like Argo CD and Flux watch a Git repository and make the cluster match it. A merge becomes a deploy.
  • Configuration and scripts: Ansible playbooks, Dockerfiles, Bash scripts, runbooks and dashboards as JSON.

When a pipeline breaks at 2 a.m., git log and git diff on the infrastructure repository are usually the fastest way to learn what changed.

Words you will use every day

TermMeaning
Repository (repo)A project folder plus its full history, stored in the hidden .git directory
Working treeThe files you see and edit
Staging area (index)The list of changes you have chosen for the next commit
CommitA saved snapshot with an ID, author, date and message
BranchA movable name that points to a commit, used for a line of work
HEADGit’s pointer to “where you are now”, usually the current branch
RemoteAnother copy of the repository, such as the one on GitHub, usually called origin
CloneA full copy of a remote repository, history included

Git in 2026: what changed

The Git you learn today is the same tool from 2005 at its core, but recent releases added commands that make daily work easier and safer. A new feature release comes out roughly every three months.

VersionDateWhat arrivedLesson
2.232019git switch and git restore split out of git checkout4, 9
2.51Aug 2025git stash export / import; switch and restore no longer experimental8
2.52Nov 2025git last-modified, git repo info, git refs list12, 18
2.53Feb 2026git repo info --all, git blame --diff-algorithm12, 18
2.54Apr 2026git history reword / split, hooks defined in config9, 13
2.55Jun 2026git history fixup, parallel hooks, built-in file monitor on Linux13, 15
2.56Sep 2026git branch --delete-merged, git add --resolved, git history drop4, 5, 9

Git 3.0 is in preparation. It will create new repositories with main instead of master, use the faster reftable format for branches and tags, and move new repositories toward SHA-256 hashes. As of November 2026 the Git project has not set a release date, and existing repositories will keep working. Lesson 18 shows how to try these defaults today.

Quick reference

TaskCommand
Check that Git is installedgit --version
Start a repositorygit init
Copy an existing repositorygit clone <url>
See what changedgit status and git diff
Save a snapshotgit add <file> then git commit -m "message"
Read the historygit log --oneline
Get help on any commandgit help <command> or git <command> -h

Exercise

A teammate’s laptop holds a clone of Orbit. The company Git server loses its disk overnight. What does that mean for Orbit’s history?

  1. It can be restored, because every clone contains the complete history
  2. It is gone, because history lives only on the server
  3. Only the latest commit can be recovered from the clone
  4. It can be restored only if the teammate had run git stash
Show answer

Answer: A. Git is distributed: a clone is a full copy of the repository, including every commit. Any up-to-date clone can be pushed to a new server to bring the history back.

Exercise

Why is a Git commit better than saving a copy called deploy-v2-final.sh?

  1. It makes the file smaller on disk
  2. It locks the file so nobody else can edit it
  3. It sends the file to production automatically
  4. It records a snapshot with an ID, author, date and message you can compare and restore later
Show answer

Answer: D. A commit captures who changed what, when and why, and links to the previous state. You can diff any two commits and go back to any of them, which no naming scheme for copies can do.

Exercise

Orbit’s deploy pipeline started failing this morning and the pipeline file lives in Git. What is the fastest first step?

  1. Rewrite the pipeline from scratch
  2. Read the recent history and diff of the pipeline file with git log and git diff
  3. Ask in chat whether anyone remembers changing something
  4. Delete the repository and clone it again
Show answer

Answer: B. When configuration lives in Git, every change is recorded. Looking at the latest commits that touched the file usually points straight at the cause.

Key takeaways

  • Git is a distributed version control system: it records snapshots called commits, each with an ID, author, date, message and parent.
  • Every clone holds the full history, so you can work offline and any clone is a backup.
  • Git is the tool; GitHub, GitLab and Bitbucket host repositories and add collaboration features.
  • In DevOps, pipelines, infrastructure code and Kubernetes manifests live in Git too, and GitOps turns merges into deploys.
  • Recent releases added git history, config-based hooks and safer cleanup commands, and Git 3.0 will switch defaults to main, reftable and SHA-256.

FAQ

Is Git hard to learn?

The basics take an afternoon: add, commit, log, diff, push and pull cover most days. What takes longer is building a mental model of commits and branches as pointers. Once that clicks, the advanced commands stop feeling scary. This course builds that model step by step.

What is the difference between Git and GitHub?

Git is the version control program that runs on your computer and works without any network. GitHub is a website that stores Git repositories and adds pull requests, issues, Actions pipelines and access control. GitLab and Bitbucket are alternatives to GitHub; they all use the same Git underneath.

Does Git store a complete copy of every file in every commit?

Conceptually yes, each commit is a full snapshot. Physically no: Git stores each unique file content once, identified by its hash, and reuses it in every commit where it did not change. It also packs similar versions together with delta compression.

Is Git only for code?

No. Any text you want history for works well: documentation, configuration, infrastructure definitions, notes. Large binary files such as videos or datasets do not diff well and bloat the repository; for those, use Git LFS or a separate storage service.

Do DevOps engineers really need Git?

Yes. Pipelines, infrastructure as code, Kubernetes manifests and GitOps all assume your changes go through Git. Reviewing, reverting and auditing infrastructure changes is done through Git history.

Should I worry about Git 3.0?

Not today. Existing repositories keep working, and SHA-1 repositories are not being removed. When Git 3.0 ships, the visible changes for most people will be the default branch name main and faster reference storage in new repositories.

↑ ↓ navigate Enter open Esc close