How to Master Git: The Complete 2027 Roadmap for Git and GitHub
A free, staged path from your first commit to confidently rebasing, recovering lost work, running team workflows on GitHub and understanding Git’s internals, with exercises, the best free resources and a command cheat sheet.
Last reviewed: December 2026 (Git 2.56, with Git 3.0 planned for spring 2027)
If you want to learn Git and GitHub properly, not just memorize add, commit, push, this roadmap is for you. Git is the version control system used by almost every software team, and GitHub is the most popular place to host Git repositories and collaborate. Most developers use a small fraction of Git and fear the rest. Mastering Git means understanding its simple underlying model, so that branching, rebasing, resolving conflicts and recovering “lost” commits become routine instead of scary.
Table of contents
- Who this roadmap is for
- Git in late 2026: what’s new and what’s coming
- The roadmap at a glance
- Stage 0: Install and configure
- Stage 1: Core everyday Git
- Stage 2: Branching and merging
- Stage 3: GitHub and collaboration
- Stage 4: Rewriting history and recovery
- Stage 5: Team workflows and conventions
- Stage 6: Power tools
- Stage 7: Git internals
- Stage 8: Automation, security and scale
- Merge vs rebase vs squash
- Branching strategies compared
- Git hosting platforms compared
- Cheat sheet
- “Oh no” recovery guide
- Best free resources
- Tools and GUIs
- Exercises and projects
- FAQ
- Where to go next
- Contributing
Who this roadmap is for
| You are… | Start at | Time |
|---|---|---|
| New to Git | Stage 0 | 4-6 weeks to comfortable, part-time |
| Use Git daily but fear rebase/conflicts | Stage 4 | 2-3 weeks |
| Leading a team | Stage 5 and 8 | 1-2 weeks |
| Curious how Git works inside | Stage 7 | 1-2 weeks |
Git in late 2026: what’s new and what’s coming
- Latest release: Git 2.56.x (2.56.1 released 26 October 2026; see git-scm.com).
- Git 2.56 highlights (GitLab’s summary): a new
git history dropcommand to remove a single commit without an interactive rebase,git branch --forkedand--delete-mergedfor branch cleanup, and continued work on pluggable object storage. - Git 3.0 roadmap: the project plans to jump from 2.56 to 2.98 (December 2026), then release 2.99 (a long-term-support release) and 3.0 together in spring 2027, according to the plan reported from the Git Merge 2026 contributor summit. The official BreakingChanges document lists what 3.0 changes, including:
maininstead ofmasteras the default initial branch name forgit init- SHA-256 as the default object hash for new repositories
- reftable as the default reference storage format
- Rust becoming a required build dependency
- What it means for you: nothing breaks in existing repositories. If you already set
init.defaultBranch, you won’t notice the branch-name change. SHA-256 repositories can’t yet interoperate with SHA-1 ones, and hosting support varies, so most people will keep using SHA-1 repositories for a while.
The roadmap at a glance
Stage 0 Install + config 1 hour identity, editor, default branch, SSH keys
Stage 1 Everyday Git 1-2 weeks init, status, add, commit, log, diff, restore
Stage 2 Branches + merging 1-2 weeks switch, merge, conflicts, remotes, fetch/pull/push
Stage 3 GitHub collaboration 1-2 weeks forks, pull requests, reviews, issues
Stage 4 History + recovery 2-3 weeks rebase -i, amend, reset, reflog, cherry-pick, revert
Stage 5 Team workflows 1-2 weeks trunk-based, GitHub flow, conventions, releases
Stage 6 Power tools ongoing bisect, worktree, stash, rerere, blame, hooks
Stage 7 Internals 1-2 weeks objects, refs, the DAG, packfiles
Stage 8 Automation + security ongoing CI, signing, secrets, monorepos, LFS
Stage 0: Install and configure (1 hour)
Install: git-scm.com/downloads lists GUIs; the command-line installer is on the main git-scm.com site. On macOS, xcode-select --install or Homebrew; on Linux, your package manager; on Windows, Git for Windows.
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
git config --global init.defaultBranch main
git config --global core.editor "code --wait" # or vim, nano...
git config --global pull.rebase false # explicit merge-on-pull (or true; pick one deliberately)
git config --global rerere.enabled true # remember conflict resolutions (Stage 6)
git config --global diff.algorithm histogram # often clearer diffs
Then set up authentication with GitHub: SSH keys or the GitHub CLI (gh auth login), which configures HTTPS credentials for you.
Stage 1: Core everyday Git (1-2 weeks)
The mental model first
Git has three places your changes live:
working directory --git add--> staging area (index) --git commit--> repository (history)
And a commit is a snapshot of the whole project plus a pointer to its parent commit(s), not a diff. Branches are just movable labels pointing at commits. Once that clicks, everything else is details.
Learn
| Command | What it does |
|---|---|
git init, git clone |
Start or copy a repository |
git status |
What changed, what’s staged (run it constantly) |
git add <file>, git add -p |
Stage changes; -p lets you stage hunk by hunk |
git commit -m, git commit |
Save a snapshot (write good messages; see Stage 5) |
git log --oneline --graph --all |
See history as a graph |
git diff, git diff --staged |
Unstaged vs staged changes |
git restore <file> |
Discard working-directory changes (docs) |
git restore --staged <file> |
Unstage |
git rm, git mv |
Remove/rename tracked files |
.gitignore |
Keep build output and secrets out (templates) |
git show <commit> |
Inspect a commit |
Resources
| Resource | Format | Notes |
|---|---|---|
| Pro Git book, chapters 1-2 | Free book (CC BY-NC-SA 3.0) | Best pick: the official, complete, free Git book |
| GitHub Docs: Hello World | Tutorial | First repo, branch and pull request on GitHub |
| freeCodeCamp: Git and GitHub for Beginners | Video crash course | Good visual start |
| Programming with Mosh: Git in 1 hour | Video | Concise |
| MIT Missing Semester: Version Control | Lecture + notes | Teaches the data model first; excellent |
Exercises
- Put a personal project (or your dotfiles) under Git. Make 10 small commits with clear messages.
- Use
git add -pto split one messy change into two logical commits. - Break a file, then restore it from the last commit.
Stage 2: Branching and merging (1-2 weeks)
Learn
git switch -c feature/git switch main(docs); older tutorials usegit checkout, which still worksgit merge: fast-forward vs three-way merge commits- Resolving conflicts: read the markers, decide,
git add,git commit(orgit merge --abort) - Remotes:
origin,git remote -v,git fetch,git pull(= fetch + merge or rebase),git push -u origin feature - Remote-tracking branches (
origin/main) and what “ahead 2, behind 3” means - Deleting branches locally and remotely
Resources
| Resource | Why |
|---|---|
| Learn Git Branching | Best pick: interactive visual puzzles for branching, merging and rebasing |
| Visualizing Git | Type commands, watch the graph change |
| Pro Git chapter 3: Git Branching | Clear explanation of branches as pointers |
| Atlassian Git tutorials | Well-illustrated articles on merging, rebasing and workflows |
Exercises
- Complete the “Main” levels of Learn Git Branching.
- Create a deliberate conflict: two branches edit the same line differently. Resolve it three times: keep ours, keep theirs, combine both.
- Clone a public repository, create a branch, push it to your own fork.
Stage 3: GitHub and collaboration (1-2 weeks)
Learn
- Forks vs branches; upstream vs origin
- Pull requests: descriptions, draft PRs, review comments, suggested changes, requesting reviews (docs)
- Keeping a branch up to date with
main - Issues, labels, milestones, Projects
- Protected branches and required status checks
CODEOWNERS, PR templates- The GitHub CLI:
gh repo clone,gh pr create,gh pr checkout 123,gh pr view --web - Open-source etiquette: read
CONTRIBUTING.md, start small, be patient (Open Source Guides)
Resources
| Resource | Cost | Why |
|---|---|---|
| GitHub Skills | Free | Interactive courses that run inside real repositories |
| GitHub Docs | Free | Official, comprehensive |
| Microsoft Learn: GitHub training | Free | Structured modules, also covers GitHub certification topics |
| GitHub certifications | Paid exams | GitHub Foundations, Actions, Advanced Security and more; optional |
| First Contributions | Free | Practice your first open-source PR safely |
| Good First Issue and Up For Grabs | Free | Find beginner-friendly issues in real projects |
Exercises
- Complete the First Contributions tutorial.
- Open a real pull request fixing a typo or doc issue in a project you use.
- Review a friend’s PR using suggested changes; have them review yours.
Stage 4: Rewriting history and recovery (2-3 weeks)
This is the stage that turns Git from scary to powerful.
Learn
| Command | Use it to… | Safe on shared branches? |
|---|---|---|
git commit --amend |
Fix the last commit’s message or content | No (rewrites) |
git rebase main |
Replay your branch on top of the latest main |
Only on your own branch |
git rebase -i HEAD~5 |
Squash, reorder, edit, drop, reword commits (docs) | Only on your own branch |
git commit --fixup <sha> + git rebase -i --autosquash |
Attach fixes to earlier commits automatically | Own branch |
git reset --soft/--mixed/--hard |
Move the branch pointer (and optionally index/working tree) | --hard destroys uncommitted work |
git revert <sha> |
Create a new commit that undoes an old one | Yes: the safe undo for shared history |
git cherry-pick <sha> |
Copy a commit to the current branch | Yes |
git reflog |
See everywhere HEAD has been; recover “lost” commits (docs) |
Local safety net |
git push --force-with-lease |
Force-push only if the remote is where you think it is | Use instead of --force |
git history drop (2.56+) |
Remove one commit and rebase its descendants | Own branch |
The golden rule: don’t rewrite history other people have already based work on. Rewriting your own unmerged feature branch is normal.
Understanding reset
git reset --soft HEAD~1 # move branch back; keep changes staged
git reset --mixed HEAD~1 # (default) move back; keep changes unstaged
git reset --hard HEAD~1 # move back; DISCARD changes (recoverable via reflog only if committed)
Resources
- Pro Git: Rewriting History
- Dangit, Git!?!: fixes for common mistakes in plain language
- Git Flight Rules: a large, organized “what to do when…” guide
- So You Think You Know Git (FOSDEM 2024 talk): lesser-known features and config
- freeCodeCamp: Git for Professionals
Exercises
- Make 6 messy “wip” commits, then use interactive rebase to turn them into 2 clean commits.
git reset --hardaway a commit, then recover it withgit reflog.- Revert a merge commit on a test repo (note the
-m 1option) and explain what happened. - Rebase a feature branch onto an updated
main, resolving conflicts commit by commit.
Stage 5: Team workflows and conventions (1-2 weeks)
Good commit messages
- Short summary line (about 50 characters, imperative mood: “Add login rate limit”)
- Blank line, then a body explaining why
- One logical change per commit
Read How to Write a Git Commit Message. Many teams also use Conventional Commits (feat:, fix:, docs:) so changelogs and version bumps can be automated.
Releases
- Tags: lightweight vs annotated (
git tag -a v1.2.0 -m "...") - Semantic Versioning
- A human-written changelog (Keep a Changelog)
Choosing a workflow
See the comparison below. Most modern web teams use trunk-based development or GitHub flow with short-lived branches, pull requests and CI.
Stage 6: Power tools (ongoing)
| Tool | What it’s for |
|---|---|
git stash / git stash -u / git stash pop |
Temporarily shelve changes |
git bisect |
Binary-search history to find the commit that introduced a bug (docs); git bisect run ./test.sh automates it |
git worktree add ../hotfix main |
Check out several branches at once in separate directories (docs); great for reviewing PRs or running parallel AI coding agents |
git rerere |
Reuse recorded conflict resolutions (docs) |
git blame -w -C -C, git log -L |
Who changed a line and why; history of a function |
git log -S "text" / -G regex |
Find commits that added or removed text (“pickaxe”) |
git switch - |
Jump back to the previous branch |
git clean -nd then -fd |
Remove untracked files (preview first) |
git sparse-checkout, partial clone (--filter=blob:none) |
Work with huge repositories |
git maintenance start |
Background repository optimization |
Hooks (.git/hooks, pre-commit framework) |
Run linters/tests before commits |
| Aliases | e.g. git config --global alias.lg "log --oneline --graph --all --decorate" |
Stage 7: Git internals (1-2 weeks)
Git is a content-addressable object store with a few kinds of objects:
| Object | Contains |
|---|---|
| blob | File contents |
| tree | A directory listing: names to blobs/trees |
| commit | A tree, parent commit(s), author, committer, message |
| tag (annotated) | A named, signed-or-not pointer to an object |
Refs (refs/heads/main, refs/tags/v1.0) are names pointing at commits. HEAD points at a ref (or directly at a commit: “detached HEAD”). The history is a directed acyclic graph (DAG) of commits.
Try it:
git cat-file -p HEAD # the commit object
git cat-file -p HEAD^{tree} # its tree
echo 'hello' | git hash-object --stdin
git rev-parse main
ls .git/refs/heads
Resources
- Pro Git chapter 10: Git Internals
- Git from the Bottom Up: free short book building up from blobs
- Think Like (a) Git: graph theory for Git users
- Julia Evans’ Confusing git terminology and her paid zine How Git Works
Mastery project: write a tiny Git clone in your language of choice that can init, hash-object, cat-file, write-tree and commit, compatible with real Git’s object format.
Stage 8: Automation, security and scale (ongoing)
| Topic | What to learn | Links |
|---|---|---|
| CI/CD | Run tests, linters and deployments on every push/PR | GitHub Actions docs |
| Signed commits | SSH or GPG signing; “Verified” badges | Commit signature verification |
| Secrets | Never commit them; scan for them; rotate any that leak | GitHub secret protection docs, gitleaks |
| Purging history | Remove a file from all history (then rotate the secret anyway) | git-filter-repo |
| Large files | Store binaries outside normal history | Git LFS |
| Monorepos | Sparse checkout, partial clone, CODEOWNERS, path-filtered CI | Git docs |
| Branch protection | Required reviews and checks, linear history, no force-push on main |
GitHub docs |
Merge vs rebase vs squash
| Merge commit | Rebase + fast-forward | Squash merge | |
|---|---|---|---|
| History shape | Non-linear, shows branch structure | Linear | Linear, one commit per PR |
| Preserves individual commits | Yes | Yes (rewritten) | No |
| Rewrites history | No | Yes (the feature branch) | Creates a new commit |
git bisect friendliness |
Good | Best | Good, but coarse |
| Best for | Long-lived branches, release merges | Clean history with well-crafted commits | Teams where PR commits are messy |
Best pick: for most teams, squash merge for PRs is simplest; if your team writes careful atomic commits, rebase and merge keeps more useful history. Use merge commits for merging long-lived branches (for example release branches).
Branching strategies compared
| Strategy | How it works | Good for | Watch out for |
|---|---|---|---|
| Trunk-based development | Everyone integrates into main at least daily; short-lived branches; feature flags |
Continuous delivery, strong CI | Needs good tests and flags |
| GitHub flow | Branch from main, PR, review, merge, deploy |
Most web apps and open source | Requires main to be always deployable |
| Git flow | develop, release/*, hotfix/*, main |
Versioned software with scheduled releases | Heavy for web apps; even its author now suggests simpler flows for continuously delivered software |
| Release branches | main plus maintained release/x.y branches; cherry-pick fixes |
Libraries/products supporting several versions | Backport effort |
Git hosting platforms compared
| Platform | Type | Notes |
|---|---|---|
| GitHub | Hosted (free + paid plans) | Largest community, Actions CI, Copilot, Codespaces |
| GitLab | Hosted or self-managed (free + paid) | Integrated DevOps platform; docs |
| Bitbucket | Hosted (free + paid) | Integrates with Atlassian tools |
| Codeberg | Hosted, non-profit, free | Community-run, based on Forgejo |
| Forgejo / Gitea | Self-hosted, open source | Lightweight self-hosting |
Cheat sheet
# Inspect
git status -sb
git log --oneline --graph --all --decorate
git diff # unstaged
git diff --staged # staged
git show <sha>
# Stage and commit
git add -p
git commit -m "Short summary"
git commit --amend --no-edit
# Branches
git switch -c feature/x
git switch main
git branch -d feature/x
git push -u origin feature/x
# Update
git fetch --prune
git pull --rebase # or merge, per team convention
git rebase origin/main
# Undo
git restore file.txt # discard unstaged changes
git restore --staged file.txt # unstage
git reset --soft HEAD~1 # undo last commit, keep changes staged
git revert <sha> # undo a pushed commit safely
git reflog # find lost commits
# Clean up history (own branch only)
git rebase -i origin/main
git push --force-with-lease
# Find things
git log -S "functionName"
git blame -w file.txt
git bisect start; git bisect bad; git bisect good <sha>
# Parallel work
git stash -u && git stash pop
git worktree add ../review-123 pr-branch
“Oh no” recovery guide
| Situation | Fix |
|---|---|
Committed to main instead of a branch |
git switch -c new-branch then git switch main and git reset --hard origin/main (only if not pushed) |
| Wrong commit message (not pushed) | git commit --amend |
| Forgot a file in the last commit | git add file && git commit --amend --no-edit |
| Need to undo a pushed commit | git revert <sha> |
| Lost commits after reset/rebase | git reflog, then git switch -c rescue <sha> |
| Rebase went wrong mid-way | git rebase --abort |
| Merge conflict mess | git merge --abort |
| Accidentally committed a secret | Rotate the secret first, then purge with git-filter-repo and force-push; assume it was already copied |
| Detached HEAD with new commits | git switch -c keep-this |
| Deleted a branch | Find its tip in git reflog and recreate it |
| Pulled and got a surprise merge commit | git reset --hard ORIG_HEAD (before doing anything else), then git pull --rebase |
More scenarios: Dangit, Git!?! and Git Flight Rules.
Best free resources
| Resource | Type | Best for |
|---|---|---|
| Pro Git | Free book | Everything; the reference |
| Git reference docs | Docs | Exact command behavior |
| Learn Git Branching | Interactive | Branching, rebasing intuition |
| Oh My Git! | Free open-source game | Learning by playing, with visualized repositories |
| Git Exercises | Exercises | Practical tasks, checked automatically |
| Git Katas | Exercises | Self-contained practice scenarios |
| MIT Missing Semester | Lectures | Git plus the shell and tools around it |
| GitHub Skills | Interactive | GitHub features |
| Atlassian Git tutorials | Articles | Workflows and comparisons |
| Git Immersion | Guided tutorial | Hands-on walkthrough (older but still accurate on fundamentals) |
| Learn Git with Tower | Free ebook/videos | Beginner-friendly (from a GUI vendor) |
| GitKraken Learn Git | Articles/videos | Beginner tutorials (from a GUI vendor) |
| git-tips | List | Handy one-liners |
| roadmap.sh | Visual roadmaps | See where Git fits in broader roadmaps |
Tools and GUIs
You should know the command line, but GUIs are great for reviewing and staging.
| Tool | Type | Cost |
|---|---|---|
| lazygit | Terminal UI | Free, open source |
| VS Code source control | Editor built-in | Free |
| GitButler | Desktop client with virtual branches | Free for individuals (check current terms) |
| GitHub Desktop | Desktop client | Free |
| GitKraken, Tower, Fork | Desktop clients | Paid (some have free tiers) |
| delta / diff-so-fancy | Prettier diffs | Free |
| GitHub CLI | PRs, issues, Actions from the terminal | Free |
| pre-commit | Hook manager | Free |
| Jujutsu (jj) | Git-compatible alternative VCS with a different model | Free; worth trying once you know Git |
The official GUI list has many more.
Exercises and projects
- Dotfiles repo: version your shell and editor config; publish it.
- Conflict lab: script that creates a repo with three conflicting branches; practice resolving them with merge, then with rebase.
- History cleanup: take a branch with 15 messy commits and produce 3 reviewable ones.
- Bisect hunt: write a repo with 100 generated commits and one bug; find it with
git bisect run. - Team simulation: with a friend (or two clones), run GitHub flow for a week: issues, PRs, reviews, protected
main, CI. - Release automation: Conventional Commits + automated changelog + tagged releases via GitHub Actions.
- Open-source contribution: land a real PR in a project you didn’t create.
- Build-your-own Git: the internals project from Stage 7.
FAQ
What’s the difference between Git and GitHub? Git is the version control tool that runs on your machine. GitHub is a hosting service for Git repositories with collaboration features (pull requests, issues, CI). GitLab, Bitbucket and Codeberg are alternatives.
How long does it take to learn Git? The daily basics: a few days. Comfortable with branches, PRs and conflicts: 2-4 weeks. Confident with rebase, recovery and internals: 2-3 months of real use.
Should I use merge or rebase? Rebase your own local/feature branch to keep it current; merge (or squash-merge) when integrating into shared branches. Never rebase commits others are building on.
Is git pull bad?
No, but know what it does: fetch plus merge (or rebase, if configured). Many people prefer git fetch then decide.
What is a detached HEAD?
You checked out a commit directly instead of a branch. Any commits you make won’t belong to a branch until you create one (git switch -c name).
git checkout vs git switch and git restore?
switch (branches) and restore (files) were added to split checkout’s two jobs. checkout still works; the newer commands are clearer.
Will Git 3.0 break my repositories?
No. Existing repositories keep working. The main visible changes are defaults for new repositories (initial branch main, SHA-256, reftable). Track the BreakingChanges page.
How do I remove a password I committed? Rotate/revoke the password immediately. Then purge it from history with git-filter-repo and force-push, and ask collaborators to re-clone. Assume anything pushed to a public repo was seen.
Do I need to know Git for a developer job? Yes. It’s one of the most universally expected skills in software teams.
Is it OK to use a GUI? Yes. Understand the concepts and CLI basics so you can debug, then use whatever makes you productive.
Where to go next
- The shell Git lives in: How to Master Linux
- Shipping what you commit: How to Master Docker
- Language roadmaps: How to Master PHP, How to Master SQL
- CI/CD: GitHub Actions in depth, then deployment pipelines
- Open source: read Open Source Guides and become a maintainer of something small
Contributing
Spotted an error, an outdated command, or a great free resource that’s missing? Open an issue or pull request. Link only to official, author-hosted or openly licensed material, mark paid resources as paid, and keep explanations in your own words.
If this helped you, a star helps others find it.
License
Content licensed under CC BY 4.0.
More free resources
Part of the Ralpberry Labs open-source collection. See also Top 100 Open Source.