Copy one commit to another branch
I need one commit from a branch, not the whole branch.
The problem
I need one commit from a branch, not the whole branch.
How the practice repository looked before
## main
fd07050 Base
The fix
[main c3f1bc0] Add b Date: Sun Jan 18 10:00:00 2026 +0000 1 file changed, 1 insertion(+) create mode 100644 b.txt
Check the result
c3f1bc0 Add b fd07050 Base
a.txt b.txt
Why this works
cherry-pick re-applies the change of one commit as a new commit on the branch you are on. feature~1 is the commit before the tip of feature, which is "Add b".
If this is not quite your case
To copy several commits in a row, give a range: git cherry-pick A..B copies the commits after A up to B. If the pick conflicts, fix the file, git add it and run git cherry-pick --continue; git cherry-pick --abort gives up cleanly.
Be careful: The copy has a different hash from the original. If you later merge the branch, Git usually copes, but you may see the change twice in conflicts.
This is an independent guide. It is not connected with the Git project, GitHub, GitLab or any company named here. Every command below was run on 14 November 2026 with the real program (git version 2.56.0.windows.4) in a new empty practice repository; the output shown is what it printed. Facts about options were read in the official Git documentation on 14 November 2026.