WeCodeAcademy

Merging Branches

git merge brings the commits of another branch into the one you are on. Switch to the branch that should receive the work, then merge.

Examplebash
Open in editor »
/ $

This was a fast-forward: main had no new commits, so Git just moved it ahead. If both branches have new commits (as below, where main moved on while hotfix was being built), Git makes a merge commit.

Examplebash
Open in editor »
/ $
Quick check

Where should you be when you run `git merge feature` to bring `feature` into `main`?

Your turn: write the code

Create feature with a new file feature.txt, merge it into main, then print how many files ls | wc -l shows (there should be two).

Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.

Tip: use the left and right arrow keys to move between lessons.