Applying Specific Commits with TortoiseGit Cherry-pick
Learn how to use the TortoiseGit Cherry-pick feature to selectively port bug fixes or features between branches without performing a full merge.
27 Dec 2025, 15:30 UTC

The Problem: Selective Feature Porting
Merging an entire branch often introduces unstable code or unwanted features when you only need a single bug fix or a specific optimization. The cherry-pick operation allows you to select a single commit from a source branch and apply its changes to your current active branch without merging the rest of the source branch's history.
Prerequisites
- A local Git repository with at least two branches (e.g.,
developandmain). - The target branch (where the change should land) must be currently checked out.
- A clean working directory. Any uncommitted changes may cause the operation to fail or lead to complex conflict resolutions.
Executing the Cherry-pick
TortoiseGit handles cherry-picking through the Log interface, allowing you to visually identify the commit hash before applying it.
- Right-click your project folder in Windows Explorer and select TortoiseGit > Show Log.
- In the Log window, use the branch selector (top left) to switch to the source branch containing the desired commit.
- Locate the specific commit you wish to port. Review the commit message and the files changed to ensure it is the correct version.
- Right-click the commit and select Cherry-pick....
- A dialog will appear. Ensure the destination is your current branch. You can choose to commit the changes immediately or leave them in the staging area for further review. Click OK.
Handling Conflict Scenarios
If the target branch has divergent changes in the same lines of code as the cherry-picked commit, Git will trigger a merge conflict. The process will pause, and you will see a "Conflict" warning.
| Scenario | Diagnostic | Resolution |
|---|---|---|
| Clean Apply | Log shows a new commit with a unique hash but identical changes. | No action needed. |
| Content Conflict | TortoiseGit prompts "Conflicts occurred". Files are marked with red icons. | Right-click conflicted files > Edit Conflicts. Resolve manually, mark as resolved, and commit. |
| Empty Commit | The changes in the source commit already exist in the target branch. | Git will notify you that the commit is empty; you can safely abort the operation. |
Verification and Validation
Because cherry-picking creates a duplicate commit with a new hash, you must verify that the logic was ported correctly without introducing regressions.
- Log Check: Open the Log for the target branch. Confirm a new commit exists with the same commit message as the source.
- Diff Comparison: Right-click the new commit and select Compare with previous to ensure the delta matches the original source commit.
- Functional Test: Run your project's build script and execute the specific regression tests associated with the ported fix.
Rollback and Recovery
If the cherry-pick introduces instability or was performed on the wrong branch, you can revert the state using the following methods:
Option A: Undo before commit
If you chose not to commit immediately and the changes are still in the working directory, right-click the folder and select TortoiseGit > Revert... to discard the cherry-picked changes.
Option B: Reset after commit
If the commit was finalized, use the Log window to identify the commit immediately preceding the cherry-pick. Right-click that commit and select Reset > Hard.
Risk: A Hard Reset permanently deletes all uncommitted changes and any commits made after the selected point. Use this only if the working directory is otherwise clean.
Limitations to Consider
Cherry-picking is a surgical operation, not a synchronization tool. Frequent use of cherry-picking instead of proper merging can lead to "duplicate commit noise" in your history. When the source branch is eventually merged into the target branch, Git is usually smart enough to recognize the identical changes, but complex conflicts may still arise due to the different commit hashes.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.