cherry-pick -n
- Git course
- Advanced
- Lesson 37/56
- 4 min
Learn no-commit application with cherry-pick -n.
cherry-pick -n
git cherry-pick -n applies the selected commit's changes to the current working area without automatically creating a new commit. -n is the short form of --no-commit. This lets you combine changes from multiple commits and save them as a single commit.
git cherry-pick -n abc1234Commit the Changes Yourself
After git cherry-pick -n, the changes remain in the working area and no automatic commit is created. Once you inspect the changes, you can check their state with git status and save them using your own commit message with git commit.
git cherry-pick -n abc1234
git status
git commit -m "Combined changes"Practice Create a No-Commit Command
Assign a command to commandText that applies commit abc1234 without creating a new commit. Then print the command.
Starter code
// Commit oluşturmadan değişiklikleri uygula
// Komutu yazdırSample solution
const commandText = "git cherry-pick -n abc1234";
console.log(commandText);Expected output
git cherry-pick -n abc1234
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 Which option applies a commit's changes without automatically creating a commit?
- --abort
- --quit
- --continue
- -n Correct answer
Explanation: <code>-n</code> applies the changes without automatically creating a commit.
2 Disable Automatic Commit
git cherry-pick ____
git cherry-pick --no-commit
Explanation: <code>--no-commit</code> applies the selected commit's changes without creating a new commit.
3 Applying Without Creating a Commit
| Term | Meaning |
|---|---|
-n |
Short no-commit option |
--no-commit |
Prevents commit creation |
git status |
Checks the working area |
git commit |
Records the changes |