Skip to content
CodeItRaw
Git Basics

Lesson 3/4

When the work on a branch is done you bring it into the main branch. The rule is simple: move to the branch that is to receive the work, then merge the other branch into it. If you want it in main, you move to main first.

git switch main
git merge fix/login
git log --oneline --graph
If no commit reached main while you worked on the branch, Git makes nothing new; it slides the main label forward to the tip of the branch. This is a fast-forward, and the history stays a straight line.

If both branches have moved on (each has commits the other lacks) a fast-forward is not possible. Git creates a new commit with two parents that joins the two tips: a merge commit. If the two branches touched different files, or different places in the same file, it sorts that out itself.

Tasks

Tasks open in order. Solve them all and the next lesson opens.

This lesson's tasks open when the lessons before it are finished. You can read the explanation now.

  1. 01

    Merge

    Git task

  2. 02

    Diverged branches

    Git task

If you would rather not wait for the order, every problem is open without locks: Problem list