Git fundamentals: commits, branches and merges
For IT staff who keep scripts, configuration or documentation in Git and need to work in a shared repository without losing work or rewriting other people's history. No previous Git experience is needed; you should be comfortable running commands in a terminal. Covers the staging area, commits and messages, branches and HEAD, fast-forward and three-way merges, resolving conflicts, undoing changes safely, and what to do if a secret gets committed.
- Level
- Beginner
- Length
- About 75 minutes
- Contents
- 5 lessons · final exam
- Status
- Published · updated 10 Oct 2026
Skills you'll practise
- Identify which staged changes the next commit will contain from git status and git diff output, and write a commit message with a short imperative summary line
- Create and switch branches, and use fetch, pull and push with remote branches
- Merge branches, tell a fast-forward merge from a merge commit, and resolve a merge conflict
- Choose a safe way to undo a change depending on whether the commit has been pushed
- Respond correctly when a password or API key has been committed
Course outline
- 1.Commits: the staging area, git status, git diff and commit messagesLesson · 14 min
- 2.Branches, HEAD and remotes: switch, fetch, pull and pushLesson · 14 min
- 3.Merging branches and resolving merge conflictsLesson · 16 min
- 4.Undoing a change safely: before and after the commit has been pushedLesson · 8 min
- 5.Responding when a password or API key has been committedLesson · 8 min
- 6.Git fundamentals: commits, branches and merges: knowledge checkKnowledge check · 14 questions
- 7.Git fundamentals: commits, branches and merges: practical exerciseKnowledge check · 1 question
- 8.Final exam10 questions · passing it completes the course, so people who already know the material can test out
Sources it draws on
The lessons and questions are written from these references, so learners can go back to the original.
- Pro Git (2nd ed.), 2.2 Git Basics: Recording Changes to the Repository
- Pro Git (2nd ed.), 3.1 Git Branching: Branches in a Nutshell
- Pro Git (2nd ed.), 3.2 Git Branching: Basic Branching and Merging
- Pro Git (2nd ed.), 3.5 Git Branching: Remote Branches
- Pro Git (2nd ed.), 2.4 Git Basics: Undoing Things
- Pro Git (2nd ed.), 5.2 Distributed Git: Contributing to a Project (commit guidelines)
- Pro Git book home page (authors, edition and CC BY-NC-SA 3.0 terms)
- Git reference manual: git-revert
- OWASP Cheat Sheet Series: Secrets Management Cheat Sheet
See it with your own jobs and topics
Tell us about your team and we'll walk you through setup, from choosing jobs to your first skills check.