What is Git?
Version control for code-the foundation of collaboration and CI/CD.
Why version control?
Git is a version control system: it tracks changes to files over time so you can revert, compare, and collaborate. Every commit is a snapshot of your project at a point in time.
Without version control, you're stuck with "final.doc" and "final_v2.doc." With Git, you have a full history, branches for experiments, and the ability to merge work from others.
Core ideas
Commit
Snapshot of your project at a point in time
Branch
Parallel line of work; merge when ready
History
Full log of commits; revert or compare anytime
No more "final_v2.doc"
Git gives you a full history, branches for experiments, and the ability to merge work from others. Every commit is a snapshot you can revert to.
Core concepts: commit, branch, merge
A commit saves a snapshot with a message. The working directory is your files; staging (git add) selects what goes into the next commit; the repository stores all commits.
Branches let you work on features or fixes without touching the main line. Merge (or rebase) brings branch changes back into another branch. main (or master) is usually the default branch.
Understanding commit/branch/merge is enough to use Git daily and to understand how pull requests and CI/CD pipelines work.
Essential Git commands
Local
git add .Stage all changesgit commit -m "msg"Create a snapshotgit branch feature-xCreate a branchgit checkout mainSwitch branchRemote
git clone <url>Copy repo to your machinegit pullFetch + merge from remotegit pushSend commits to remoteWorking with remotes
A remote is a copy of the repo elsewhere (e.g. GitHub, GitLab). clone copies a remote to your machine; pull fetches and merges updates; push sends your commits to the remote.
origin is the default name for the remote you cloned from. fetch downloads new commits without merging; pull = fetch + merge.
Remotes enable collaboration: everyone pushes to the same repo, and pull requests (or merge requests) propose merging a branch after review.
Common workflows
Feature branch: create a branch (e.g. feature/login), commit, push, open a pull request (PR) to merge into main. Review and merge.
Trunk-based: short-lived branches, frequent merges to main. Git flow uses long-lived develop and release branches. Most teams use something in between.
Rebase vs merge: merge creates a merge commit; rebase replays your commits on top of another branch for a linear history. Both are valid; teams choose one style.
Common workflows
Feature branch
Create branch β commit β push β open PR β merge into main
Merge vs rebase
Merge: keeps history; Rebase: linear history. Teams pick one.
Pull request
Propose merging your branch; review, then merge.
Merge, rebase, and more
Merge combines two branches with a merge commit. History shows when branches came together. Rebase takes your branch's commits and replays them on top of another branch (e.g. main). Result: a linear history as if you had started from the latest main. Use rebase to keep a clean history; never rebase commits already pushed if others use that branch.
Stash (git stash) temporarily saves uncommitted changes so you can switch branches or pull without committing. git stash pop brings them back. Revert (git revert <commit>) creates a new commit that undoes a previous one-safe for shared history. Cherry-pick (git cherry-pick <commit>) applies one specific commit from another branch onto your current branch.
Conflicts happen when two branches change the same lines. Git marks conflict regions in the file; you edit, resolve, then git add and git commit (merge) or git rebase --continue (rebase).
Merge vs rebase
Merge
git merge featureCreates a merge commit that joins two branches. History shows both branches and when they combined.
- β’ Preserves full history
- β’ Safe, no rewrite
- β’ Shows when branches joined
Rebase
git rebase mainTakes your branch's commits and replays them on top of main. Result: a linear history as if you had started from the latest main.
- β’ Linear, clean history
- β’ Easier to read
- β’ Don't rebase pushed commits
Stash, revert, cherry-pick, conflicts
Stash
git stashgit stash popTemporarily save uncommitted changes. Switch branches or pull without committing. Pop brings changes back.
Revert
git revert <commit>Creates a new commit that undoes a previous commit. Safe for shared historyβno rewrite.
Cherry-pick
git cherry-pick <commit>Apply one specific commit from another branch onto your current branch. Copy a single fix or feature.
Conflicts
Edit file β git add β git commitWhen two branches change the same lines, Git marks conflict regions. Edit, resolve, then add and commit (or rebase --continue).
Concepts that transfer
Git is the input to CI/CD: pipelines run on every push or PR. Understanding branches and commits helps you design workflows and fix broken builds.
Cloud and DevOps: infrastructure as code (Terraform, Ansible) lives in Git. GitOps uses Git as the source of truth for deployments.
Every role-developer, DevOps, SRE-benefits from confident Git use: small commits, clear messages, and knowing how to undo mistakes.
Git skills apply everywhere
CI/CD
Pipelines run on every push or PR. Branches and commits are the input.
GitOps & IaC
Terraform, Ansible, K8s manifests live in Git. Git as source of truth.
Collaboration
Everyone pushes to the same repo; PRs and reviews keep quality high.
Sign in to track progress on your dashboard.
Ready to see how this works in the cloud?
Switch to Career Paths on the Academy page for structured paths (e.g. Developer, DevOps) and provider-specific lessons.
View role-based paths