CodeBlanks Logo Icon CodeBlanks

Summary - Merging

Combine merge types to build a branch flow.

Merge Summary

When merging branches in Git, you must be on the target branch and merge the source branch with git merge. If the target branch has no independent commits, a fast-forward may occur; if both branches have diverged, a three-way merge can be used.

git switch main
git merge feature

A three-way merge generally creates a merge commit with two parents. This preserves the history of both branches.

Practice Print a Merge Workflow

Store the git switch main and git merge feature commands in a JavaScript array, in that order. Use forEach to print each command on a separate line.

Starter code

terminal
const commands = [
    // Hedef dal ve birleştirme komutlarını ekle
];

// Komutları sırayla yazdır

Sample solution

terminal
const commands = [
    "git switch main",
    "git merge feature"
];

commands.forEach(command => console.log(command));

Expected output

git switch main
git merge feature

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 Which merge type is used when both branches contain separate commits after their common ancestor?

  • Fast-forward
  • Three-way merge Correct answer
  • File deletion
  • Global configuration

Explanation: When both branches have progressed independently, Git performs a three-way merge by considering the common ancestor and the latest commits of both branches.

2 Identify the Target Branch Pointer

Question
git switch main
git status
____
Answer
git switch main
git status
git log --oneline

Explanation: Before merging, git log --oneline can be used to inspect the target branch status and commit history.

3 Distinguish Merge Types

Term Meaning
git merge Brings the source into the target
Fast-forward Moves the pointer forward
Üç yönlü birleştirme Uses the ancestor and two tips
Merge commit Has two parents

All lessons in Beginner