CodeBlanks Logo Icon CodeBlanks

cherry-pick range

Learn to cherry-pick a commit range.

Move Multiple Commits

With git cherry-pick, you can select multiple commits and apply them to the current branch. Using a commit range makes it easier to transfer consecutive commits together. Whether the first commit is included depends on the range notation you use.

git cherry-pick abc1234..def5678

Specify the Range Order Correctly

In a commit range, write the starting reference first, followed by the ending reference. For example, abc1234..def5678 selects commits after the starting point, including the ending commit. Git applies the selected commits to the current branch in the appropriate order.

git cherry-pick abc1234..def5678

This operation transfers the changes from the selected commits to the target branch.

Practice Apply a Commit Range

Assign a command to commandText that applies commits in the range from 111aaaa to 999bbbb to the current branch. Then print the command.

Starter code

terminal
// Commit aralığını uygula
let commandText = "";

// Komutu yazdır

Sample solution

terminal
let commandText = "git cherry-pick 111aaaa..999bbbb";
console.log(commandText);

Expected output

git cherry-pick 111aaaa..999bbbb

Questions and answers

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

1 How is the starting commit treated in a standard two-dot commit range?

  • It is deleted automatically
  • It is always applied twice
  • It is excluded from the range Correct answer
  • Only its message is transferred

Explanation: In <code>abc1234..def5678</code>, the starting commit is excluded and subsequent commits up to the ending commit are selected.

2 Complete the Commit Range

Question
git cherry-pick ____
Answer
git cherry-pick abc1234..def5678

Explanation: The two-dot notation specifies the starting and ending commit references as a range.

3 Commit Range Parts

Term Meaning
abc1234 Starting reference
def5678 Ending reference
.. Range notation
Commit sırası Determines application order

All lessons in Advanced