git cherry-pick should be your answer here.

Apply the change introduced by an existing commit.

Do not forget to read bdonlan's answer about the consequence of cherry-picking in this post:
"Pull all commits from a branch, push specified commits to another", where:

A-----B------C
 \
  \
   D

becomes:

A-----B------C
 \
  \
   D-----C'

The problem with this commit is that git considers commits to include all history before them

Where C' has a different SHA-1 ID.
Likewise, cherry picking a commit from one branch to another basically involves generating a patch, then applying it, thus losing history that way as well.

This changing of commit IDs breaks git's merging functionality among other things (though if used sparingly there are heuristics that will paper over this).
More importantly though, it ignores functional dependencies - if C actually used a function defined in B, you'll never know.

Answer from VonC on Stack Overflow
๐ŸŒ
DEV Community
dev.to โ€บ iamafro โ€บ how-to-merge-a-specific-commit-into-another-branch--oak
How to merge a specific commit into another branch - DEV Community
February 15, 2018 - First you checkout the branch you want to merge the commits into ... What this does is, "It applies the change introduced by the commit at the tip of the working branch and creates a new commit with this change". The issue I had with that was, I had made a couple of commits and I needed all those commits in the master branch. That's when I found it. What did I find? you may be asking. Gitlens is what I found.
Discussions

github - How do I merge a specific commit from one branch into another in Git? - Stack Overflow
The git cherry-pick command ... a single commit (from whatever branch) and, essentially, rebase it in your working branch. Chapter 5 of the Pro Git book explains it better than I can, complete with diagrams and such. (The chapter on Rebasing is also good reading.) Lastly, there are some good comments on the cherry-picking vs merging vs rebasing in another SO ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
How to merge branches to a specific commit
git switch main; git merge 1.0.1 โ€”ff-only; More on reddit.com
๐ŸŒ r/git
5
6
January 14, 2021
git - Merge up to a specific commit - Stack Overflow
I created a new branch named newbranch from the master branch in git. Now I have done some work and want to merge newbranch to master; however, I have made some extra changes to newbranch and I want to merge newbranch up to the fourth-from-the-last commit to master. More on stackoverflow.com
๐ŸŒ stackoverflow.com
git - How to merge specific commit id from different branch in same repo - Stack Overflow
I had two branches master & trunk. I have created one more branch in local using git checkout -b new_branch origin/master to take the master code in that branch. I have added committed some c... More on stackoverflow.com
๐ŸŒ stackoverflow.com
๐ŸŒ
Better Stack
betterstack.com โ€บ community โ€บ questions โ€บ how-to-merge-specific-commit
How to Merge a Specific Commit in Git | Better Stack Community
August 12, 2024 - Use the cherry-pick command to apply the changes from the specific commit onto the current branch. ... Replace <commit-hash> with the hash of the commit you want to apply. If the commit being cherry-picked causes conflicts with the current branch, ...
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ git โ€บ how-to-merge-commits-in-git
How to Merge Commits in Git? - GeeksforGeeks
July 23, 2025 - ... This method allows you to merge all changes from a branch but combine them into a single commit. ... git checkout main git merge --squash feature git commit -m "Merged feature branch as a single commit"
๐ŸŒ
W3docs
w3docs.com โ€บ git
How to Merge a Specific Commit in Git | W3Docs
Below, you will find out how to do it by using git cherry-pick. Now letโ€™s follow these steps to get the job done appropriately: First of all, you need to download all the changes from the ...
Find elsewhere
๐ŸŒ
Reddit
reddit.com โ€บ r/git โ€บ how to merge branches to a specific commit
r/git on Reddit: How to merge branches to a specific commit
January 14, 2021 -

I have two branches, main and develop. Lets say that this is my current commit history:

A - B - C - D (main) (tag 1.0.0) - E - F - G (tag 1.0.1) - H (develop)

I want to bring main to G (tag 1.0.1) so that it is one commit behind develop. Note that, I want all commits between main and G to also be included. Would I use cherry-pick or is there a better way?

๐ŸŒ
Matt Stauffer
mattstauffer.com โ€บ blog โ€บ how-to-merge-only-specific-commits-from-a-pull-request
How to merge only specific commits from a pull request with git cherry-pick | MattStauffer.com
Git's cherry-pick command allows you to "cherry pick" only the commits you want from another branch. ... Pull down the branch locally. Use your git GUI or pull it down on the command line, whatever you'd like.
๐ŸŒ
Linux Hint
linuxhint.com โ€บ merge-specific-commit-git
How to Merge a Specific Commit in Git โ€“ Linux Hint
To merge the specific Git commit, first, visit the Git repository. Note the commit id you need to merge. After that, switch to the branch in which you are merging the specific commit of another branch. Next, merge the commit using the โ€œ$ git cherry-pick <commit-id>โ€ command.
๐ŸŒ
Delft Stack
delftstack.com โ€บ home โ€บ howto โ€บ git โ€บ git merge specific commit
How to Merge a Specific Commit in Git | Delft Stack
March 11, 2025 - Merging a specific commit in Git is a valuable skill that can enhance your workflow and make managing changes more efficient. By utilizing commands like git cherry-pick and git rebase, you can selectively incorporate changes from one branch ...
๐ŸŒ
W3Guy
w3guy.com โ€บ git-merge-commit-from-another-branch
Git: Merge a Specific Commit From One Branch to Another
May 28, 2016 - Scenarios like this is where git cherry-pick comes in handy. A cherry-pick is like a rebase for a single commit. It takes the patch that was introduced in a commit and tries to reapply it on the branch youโ€™re currently on.
๐ŸŒ
Codemia
codemia.io โ€บ home โ€บ knowledge hub โ€บ how to merge a specific commit in git
How to merge a specific commit in Git | Codemia
January 2, 2025 - Git is a distributed version control system used widely by developers for managing the source code. It allows multiple developers to work on the same project simultaneously without interfering with each other's work. One of Git's powerful features is the ability to selectively merge specific commits from one branch into another.
๐ŸŒ
Git
git-scm.com โ€บ docs โ€บ git-merge
Git - git-merge Documentation
This allows you to create a single commit on top of the current branch whose effect is the same as merging another branch (or more in case of an octopus). With --no-squash perform the merge and commit the result. This option can be used to override --squash. With --squash, --commit is not allowed, and will fail. ... By default, the pre-merge and commit-msg hooks are run. When --no-verify is given, these are bypassed. See also githooks[5]. ... Use the given merge strategy; can be supplied more than once to specify them in the order they should be tried.
๐ŸŒ
Codementor
codementor.io โ€บ community โ€บ how to merge a specific commit into another branch
How to merge a specific commit into another branch | Codementor
February 15, 2018 - First you checkout the branch you want to merge the commits into ... What this does is, "It applies the change introduced by the commit at the tip of the working branch and creates a new commit with this change". The issue I had with that was, I had made a couple of commits and I needed all those commits in the master branch. That's when I found it. What did I find? you may be asking. Gitlens is what I found.
๐ŸŒ
Better Stack
betterstack.com โ€บ community โ€บ questions โ€บ how-to-selectively-merge-or-pick-changes-from-another-branch-in-git
How Can I Selectively Merge or Pick Changes from Another Branch in Git? | Better Stack Community
Check out specific files: Check out specific files or directories from other-branch-name into your current branch: ... Replace path/to/file1 path/to/dir1 with the paths to the files or directories you want to bring in. Commit Hash: Always verify the commit hash or reference of the changes you want to pick or merge. Conflicts: Be prepared to resolve conflicts when merging or applying changes. Branch Switching: Use git checkout to switch between branches as necessary before executing commands.