About this course
About this course
This free course teaches you Git from the ground up - no prior experience needed. You'll start by understanding what version control is, make your first commits, and learn the mental model (working directory, staging area, repository) that makes everything else click.
From there you'll branch and merge with confidence, push and pull with GitHub, collaborate through pull requests, and - the part everyone needs - undo mistakes: amend, reset, revert, stash, and recover lost work with the reflog. The later chapters cover rewriting history (rebase, interactive rebase, cherry-pick) and a troubleshooting chapter built around the exact problems you will Google.
Every lesson builds on the previous one, with small, runnable commands you can try in a real repository. By the end you'll use Git day to day without fear, and know how to get yourself out of trouble when something goes wrong.
It's written for developers who will actually use Git every day, not just memorize commands.
Course curriculum
- What is Git? What is Git and what does version control mean? Learn how Git tracks changes, lets you work in parallel, and makes sure you never lose your work.
- Installing Git Install Git in a few minutes on Windows, macOS or Linux, then confirm it worked with git --version. Beginner-friendly steps for every system.
- Configuring Git Configure Git after installing: set your name and email with git config, learn --global vs local config, and make main the default branch.
- Your first repository Create your first Git repository with git init. See what the hidden .git folder holds and why a repo is just a folder Git has started tracking.
- The three areas Git's core mental model: the working directory, the staging area (index) and the repository, plus how a single change moves through all three.
- Checking status with git status Read git status output line by line: tell untracked, modified and staged files apart so you always know your Git repository's exact state.
- Staging changes with git add Use git add and the staging area to stage specific files or run git add . - and control exactly what goes into your next Git commit.
- Committing with git commit Run git commit and git commit -m to save staged changes. Learn what a commit really is: a snapshot with a message, author and parent link.
- Committing only specific files Commit only chosen files in Git: stage named files, commit a path directly, or use git add -p to stage selected hunks within a single file.
- Writing good commit messages Write clear Git commit messages: a concise imperative subject line, a body that explains why not what, and common conventions teams follow.
- Viewing history with git log Read your Git history with git log and its most useful flags: --oneline, --graph, -p and -n to see commits the way you need them.
- Seeing changes with git diff See exactly what changed in Git: git diff shows unstaged edits, git diff --staged shows what's ready to commit. Read the diff output line by line.
- Ignoring files with .gitignore Use a .gitignore file to keep files out of Git: pattern syntax, per-project vs global ignore, and why it only affects untracked files, not tracked ones.
- Moving and removing files Remove and move files in Git: git rm to delete, git rm --cached to untrack while keeping the file on disk, and git mv to rename or relocate.
- Empty directories and .gitkeep Git ignores empty folders because it tracks files, not directories. Learn how to commit an empty directory with .gitkeep, plus .gitkeep vs .gitignore.
- What is a branch? What a Git branch really is: a lightweight, movable pointer to one commit. Understand HEAD, why main is just a branch, and why branches cost almost nothing.
- Creating and switching branches Create a branch with git branch, move onto it with git switch, do both at once with git switch -c, and list your branches. Plus how git checkout fits in.
- Merging branches How git merge works: bring a feature branch into main, tell a fast-forward apart from a merge commit, and check the result with git log --oneline.
- Resolving merge conflicts Resolve a Git merge conflict: read the conflict markers, edit the file, then git add and git commit to finish - or git merge --abort to back out safely.
- Deleting branches Delete a Git branch safely with git branch -d, force-delete an unmerged branch with -D, and see why clearing out merged branches keeps your repo tidy.
- What is a remote? Understand what a Git remote is - a copy of your repo hosted on GitHub - why it's named origin, and how to list remotes with git remote -v.
- Cloning a repository How git clone works: copy a GitHub repository to your machine with full history, a working copy, and origin set up so push and pull just work.
- Adding a remote Started a repo with git init? Create an empty GitHub repo and connect it with git remote add origin so your local commits have somewhere to push.
- Pushing changes What git push does, how git push -u origin main sets the upstream branch, and why every push after that is just a plain git push on its own.
- Fetching and pulling The difference between git fetch and git pull: fetch downloads new commits without touching your files; pull fetches and merges them into your branch.
- HTTPS vs SSH authentication Git HTTPS vs SSH for GitHub: authenticate with a personal access token over HTTPS or SSH keys from ssh-keygen. See the difference and which to pick.
- Git submodules Git submodules explained: add another repository inside yours, clone a project with submodules, update them, and avoid the empty-folder trap.
- The feature branch workflow Learn the Git feature branch workflow: branch off main per feature, commit, push, open a pull request and merge back - and why you never commit to main.
- Pull requests What a GitHub pull request is and how to open one, get it reviewed and merged - and how a PR maps to a plain git merge under the hood.
- Keeping your branch up to date main moved while you worked? Learn to update your feature branch by merging the latest main into it so your pull request stays current and mergeable.
- Handling push rejections (non-fast-forward) Git push rejected with '! [rejected] ... (non-fast-forward)'? Someone pushed first. Learn to git pull then push, and why you should never force-push shared branches.
- Forking a repository Learn to fork a GitHub repository: clone your fork, add an upstream remote, keep your fork in sync with the original, and open a pull request from a fork.
- Amend the last commit with git commit --amend Fix your last Git commit message or add a forgotten file with git commit --amend - and why you should never amend a commit you already pushed.
- Unstage a file in Git Unstage a file in Git with git restore --staged (or the older git reset HEAD) without losing a single edit. Here is how, and the trap to avoid.
- Discard changes in Git How to discard uncommitted changes in Git with git restore. A destructive command with no undo - the changes are gone for good, so read first.
- git reset --soft vs --hard explained git reset --soft vs --hard vs --mixed against HEAD~1: what each mode keeps and what it deletes, with a clear table and when to reach for which.
- Revert a commit with git revert How to revert a commit with git revert - a new commit that cancels an old one, safe on shared branches, plus how git revert differs from git reset.
- Stash work in progress with git stash Use git stash, pop, list and drop to shelve unfinished changes, switch branches with a clean tree, then bring your work back exactly where you left it.
- Recover lost commits with git reflog Use git reflog to find and recover a commit that seems lost after a bad git reset, then restore it with git reset or a new branch. Git's safety net.
- Rebase vs merge Git rebase vs merge, explained with diagrams: merge keeps history and adds a merge commit, rebase replays commits for a linear history. When to use each.
- Interactive rebase Clean up a branch before a pull request with git interactive rebase: squash commits, reword, reorder, edit and drop, step by step for beginners.
- Cherry-picking commits Git cherry-pick copies one specific commit onto your current branch by its hash. When to use it, how to handle a cherry-pick conflict, and common mistakes.
- Tags and releases Mark releases with git tag: lightweight vs annotated tags, pushing tags with git push --tags, and a quick note on semantic versioning like v1.2.0.
- When not to rewrite history The golden rule of Git: never rewrite commits others have pulled. Force-push dangers explained, plus why --force-with-lease is safer than --force.
- gitignore not working Your .gitignore is not working because the file is already tracked by Git. Fix it with git rm --cached, then commit. Full explanation and examples.
- Undo last commit Undo your last Git commit: keep the changes with git reset --soft, discard them with git reset --hard, or safely undo a pushed commit with git revert.
- Detached HEAD What 'You are in detached HEAD state' means in Git, how you ended up there, and how to get back to a branch with git switch - keeping or discarding your work.
- Committed to the wrong branch Committed to main instead of a feature branch? Move the commit onto a new branch with git switch -c, then reset main back - safe, step-by-step fix.
- Remove a file from Git history Committed a secret or huge file? git rm --cached fixes the future; to purge it from all history use git filter-repo or BFG. Rotate the secret and force-push.
- A sensible Git workflow A practical everyday Git workflow for beginners, solo or on a team: main plus feature branches, small commits, pull before push, pull requests, merge vs rebase.