CodeBlanks Logo Icon CodeBlanks

cherry-pick strategy

Learn to choose a merge strategy.

Cherry-pick Merge Strategy

During cherry-pick, Git uses its merge mechanism to apply commit changes to the current branch. You can specify a merge strategy with the -s option. Choosing a strategy becomes important when you want to control how changes from different histories are merged.

git cherry-pick -s ort

Use the ort Strategy

ort is a merge strategy used in modern versions of Git. You can explicitly specify this strategy by writing -s ort in the cherry-pick command. Git then merges the selected commit's changes with the current branch using the ort strategy.

git cherry-pick -s ort abc1234

Practice Create a Cherry-Pick Strategy Command

Assign a command to commandText that applies commit abc1234 using the ort strategy. Then print the command.

Starter code

terminal
// Ort stratejisiyle cherry-pick yap
let commandText = "";

// Komutu yazdır

Sample solution

terminal
let commandText = "git cherry-pick -s ort abc1234";
console.log(commandText);

Expected output

git cherry-pick -s ort abc1234

Questions and answers

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

1 Which option specifies a merge strategy during cherry-pick?

  • -m
  • -s Correct answer
  • -n
  • -x

Explanation: <code>-s</code> lets you select a merge strategy for the cherry-pick operation.

2 Specify the Strategy

Question
git cherry-pick -s ort____
Answer
git cherry-pick -s ortort

Explanation: <code>ort</code> is a merge strategy that can be explicitly selected during cherry-pick.

3 Strategy Options

Term Meaning
-s Strategy option
ort Modern merge strategy
recursive Older merge strategy
abc1234 Commit identifier to apply

All lessons in Advanced