Git Tutorial
Learn Git from scratch: version control basics, branching, merging, rebasing, remotes, GitHub workflow, and advanced techniques, with hands-on examples and quizzes.
17 lessons in this tutorial
Introduction to Git
Learn what Git is and why version control matters: distributed versus centralized systems, how Git stores history and the key terms to know first.
Installing Git
Install Git on macOS, Linux and Windows, then configure what matters: your identity, default branch, editor and .gitattributes for consistent line endings.
Git Basics
Learn the everyday Git loop with init, clone, status, add, commit, log and diff, understand the staging area and build checks to run before every commit.
Git Branching
Learn what a Git branch really is, git switch versus checkout, how HEAD and detached HEAD work, and how to delete, rename and name branches well.
Git Merging
Learn git merge: fast-forward versus three-way merges, resolving conflict markers step by step, --no-ff and squash merges, and aborting a bad merge.
Git Rebasing
Use git rebase for a linear history: basic and interactive rebase, squashing, recovering with --abort and reflog, force-with-lease, and when to merge instead.
Git Remote
Work with Git remotes confidently: fetch versus pull, fixing a rejected push without force, upstream tracking, pruning branches and origin versus upstream.
Git Stash
Park work in progress with git stash: apply versus pop, stash untracked files, name and inspect stashes, and decide when a branch is the better tool instead.
Undoing Changes in Git
Undo almost anything in Git: restore files, reset soft, mixed and hard, revert on shared branches, clean untracked files and recover a bad reset with reflog.
Git Tagging
Mark releases with Git tags: lightweight versus annotated, why push ignores tags, deleting them safely, tagging older commits and semantic-versioned releases.
GitHub Workflow with Git
Follow the GitHub pull request workflow end to end: fork versus clone, keeping a branch current, squash versus merge versus rebase, and reviewing well.
Advanced Git
Learn advanced Git: cherry-pick a commit, find a regression with git bisect, recover lost work with reflog and trace changes with blame, in learning order.
Git Hooks
Automate checks at commit and push time with Git hooks: where they live, why they never reach your team, client versus server hooks, --no-verify and Husky.
Git Workflows
Compare GitFlow, GitHub Flow and trunk-based development honestly, see which suits which team, why long-lived branches hurt and how feature flags help.
Git Aliases and Configuration
Configure Git once and stop fighting it: .gitconfig scopes, per-directory identities with includeIf, handy aliases and the defaults worth changing.
Git Submodules
Pin one repository inside another with Git submodules: clone with --recurse-submodules, know the two update commands, handle detached HEAD and subtrees.
Git Commit Messages
Write Git commit messages that stay useful: an imperative summary, a body that records why, Conventional Commits and enforcement with commitlint and Husky.
Git Tutorial: common questions
How long does it take to learn Git?
The everyday commands, add, commit, push, pull and branch, take a day or two. Merging, rebasing, resolving conflicts and recovering lost work take a few weeks of real use to feel natural.
What is the difference between Git and GitHub?
Git is the version control tool that runs on your machine. GitHub, GitLab and Bitbucket are hosting services that store Git repositories online and add pull requests, issues and CI/CD on top.
Should I use merge or rebase?
Merge preserves the exact history of how work came together. Rebase rewrites your branch on top of the latest main for a linear history. A common rule is to rebase your own local branches and merge shared ones.