Tutorial

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

1

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.

2

Installing Git

Install Git on macOS, Linux and Windows, then configure what matters: your identity, default branch, editor and .gitattributes for consistent line endings.

3

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.

4

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.

5

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.

6

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.

7

Git Remote

Work with Git remotes confidently: fetch versus pull, fixing a rejected push without force, upstream tracking, pruning branches and origin versus upstream.

8

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.

9

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.

10

Git Tagging

Mark releases with Git tags: lightweight versus annotated, why push ignores tags, deleting them safely, tagging older commits and semantic-versioned releases.

11

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.

12

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.

13

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.

14

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.

15

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.

16

Git Submodules

Pin one repository inside another with Git submodules: clone with --recurse-submodules, know the two update commands, handle detached HEAD and subtrees.

17

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.