ILILCode
HomeGitBranching

Merging: bringing an idea back

Move the work from a branch onto main, and understand what a conflict actually asks you to do.

Lesson 7 of 9 in Git8 min1 exercise

Merging takes the commits from one branch and adds them to another. You merge into the branch you are standing on, so switch to the destination first.

The whole operation
git switch main
git merge feedback

# when main has not moved since the branch was created:
# Fast-forward

# otherwise Git creates a merge commit with two parents

A fast-forward just moves the pointer — no new commit. If both branches have new commits, Git creates a merge commit so the history records both parents.

When a conflict happens

git merge feedback
# CONFLICT (content): Merge conflict in notes.txt

# edit the file: keep the right lines, delete the markers
# <<<<<<< HEAD
# =======
# >>>>>>> feedback

git add notes.txt
git commit -m "Resolve merge conflict"

Exercises

Checked in your browser · hints and solutions included

01

Exercise

Merge the branch

You are on main and the feedback branch is ready. Merge it into the branch you are on.

terminal