Track

Branching & Merging

7 Lessons, then a Checkpoint of 5 Challenges.

Builds on Basics.

Lessons

Follow them in order, or play any Lesson once the Track is unlocked.

  1. Branches

    A branch is a name for a line of work. Under the hood it's tiny: a label that points at one commit. Here, every new repository starts on a branch called main…

    4 Challenges.

    New commands:

    • git branch
    • git branch -d
    • git branch -D
    • git branch -m
    • git switch
    • git switch -c
  2. Fast-forward merges

    A branch lets you work on something without touching main. When the work is done, you merge it: git merge <branch> brings that branch's commits into the…

    3 Challenges.

    New commands:

    • git merge
  3. Merge commits

    A fast-forward only works while your branch hasn't moved since the other one split off. Often both have: you committed on main while contact was still in…

    3 Challenges.

    New commands:

    • git merge --no-ff
  4. Merge conflicts

    A merge combines what each branch changed since they split. Changes to different files combine by themselves, and so do changes to one file with an unchanged…

    3 Challenges.

    New commands:

    • git merge --abort
  5. Switching with uncommitted work

    Changes you haven't committed come along when you switch branches, as you saw in Branches. But when the other branch has a different version of a file you…

    3 Challenges.

    New commands:

    • git stash push
    • git stash push -m
    • git stash push -u
    • git stash list
    • git stash pop
    • git stash apply
    • git stash drop
  6. HEAD and relative refs

    HEAD is git's name for where you are. Most of the time it points at a branch, the one you're on, and through that branch at its newest commit. That's why a…

    3 Challenges.

    New commands:

    • git switch --detach
  7. Tags

    A tag is a name for one commit, like a branch. The difference is that a tag never moves. When you commit, the branch you're on moves to the new commit, and…

    3 Challenges.

    New commands:

    • git tag
    • git tag -a
    • git tag -m
    • git tag -d

Checkpoint

The Track ends with a Checkpoint of 5 Challenges that use only this Track's commands and those of the Tracks it builds on. Passing the Checkpoint completes the Track, even before you have played every Lesson.

Play the Branching & Merging Checkpoint