Skip to content

Cherry-选取

一句话解释

Cherry-选取 applies 更改从 one 特定提交到 你的 current 分支, 不使用合并整个源 分支.

用大白话说

git cherry-pick <commit> takes a single commit from anywhere in the repository and applies its changes to your current branch as a new commit. It is like copying one commit and pasting it onto your branch.

Cherry-pick is useful when you need a specific bug fix or feature from another branch but do not want to merge the entire branch. For example, if a bug fix is on a feature branch that also contains unfinished work, you can cherry-pick just the fix commit to main.

The cherry-picked commit gets a new hash (it is a new commit with the same changes). If the changes conflict with your current branch, Git pauses and asks you to resolve the conflicts, just like a merge.

示例

bash
# Apply a specific commit to current branch
git cherry-pick abc123

# Cherry-pick without committing (to combine with other changes)
git cherry-pick --no-commit abc123

Cherry-选取 applies one 提交's 更改到 current 分支.

相关术语

相关资源

相关课程

解读错误信息

用大白话解释常见错误——什么意思、为什么发生、如何修复。

查看错误

← 返回术语表