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

Merge but exclude certain commits
If you want to merge while ignoring changes to some files you can use a custom merge driver using .gitattributes I've done it for my home repository where I want to ignore changes to .Brewfile so the .gitattributes file has this line .Brewfile merge=ours And the driver is configured via git config --global merge.ours.driver true This will cause the true command to be run for this file upon merge, essentially telling git to ignore the incoming changes and always use "ours" side for that particular file. I don't recall if this change needs to be on both branches already in order for it to work or if it only needs to be on mainline, so let me know what worked. If you don't want the merge to automatically commit use the --no-commit flag. More on reddit.com
๐ŸŒ r/git
13
3
April 1, 2024
How can we merge only specific files from one branch into another in Azure DevOps, even if those files are part of the same commit or spread across multiple commits?.
This means that if the commit contains ... the new commit on the target branch after the cherry-pick operation. If your goal is to merge only specific files from one branch into another, you'll need to take a different approach. One common method is to manually check out the particular files you want from the source branch and then add them to the target branch. You can accomplish this using Git commands in ... More on learn.microsoft.com
๐ŸŒ learn.microsoft.com
1
0
August 4, 2025
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
Remove all changes merged from a specific branch
The git revert command is able to revert a merge, but you won't be able to merge those commits again. I guess it may work if you rebase the commits you are interested in on the feature branch or create a new feature branch and cherry-pick the commits. Reverting a merge commit declares that you will never want the tree changes brought in by the merge. As a result, later merges will only bring in tree changes introduced by commits that are not ancestors of the previously reverted merge. More on reddit.com
๐ŸŒ r/git
13
1
July 18, 2024
๐ŸŒ
Git
git-scm.com โ€บ docs โ€บ git-merge
Git - git-merge Documentation
Pass merge strategy specific option through to the merge strategy. ... Verify that the tip commit of the side branch being merged is signed with a valid key, i.e. a key that has a valid uid: in the default trust model, this means the signing key has been signed by a trusted key.
๐ŸŒ
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, ...
๐ŸŒ
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
I knew I could copy the code in ... git?" Turns out? You can grab only specific commits with a very simple git command: git cherry-pick....
Find elsewhere
Top answer
1 of 1
1

Hi Meera Rajasekharan Pillai (Infosys Ltd)

In addition to Naveen's response,

In Azure DevOps, merging specific files from one branch to another can be done using the cherry-pick option, but it does not allow for selecting individual files from a commit.

It only allows for selecting entire commits. To merge specific files, you may need to manually apply changes or use a pull request with selective file modifications.

The cherry-pick option in Azure DevOps allows you to select specific commits to merge into another branch. It does the following:

  1. Creates a new branch from the PR's target branch.
  2. Cherry-picks all changes from the PR's source branch to the new branch.
  3. Then it will prompt you to create a new pull request to merge the new branch into another target branch.

Refer to this document - https://learn.microsoft.com/en-us/azure/devops/repos/git/cherry-pick?view=azure-devops&tabs=browser

So, if the commit has multiple files, you cannot pick only some files. That means if you try to cherry-pick a commit that changes 5 files, but you want only 2 of them, then you cannot be able do this.

Pull requests means merging changes from one branch to another. Excluding files is not possible via PR's. You can create a pull request and modify the files in the pull request before merging. This will allow you to exclude the unwanted changes.

You can also use Git manually to bring in only the files you need, and then commit directly, or you can push to another new branch and raise a PR.

Additional Reference:

https://stackoverflow.com/questions/5717026/how-can-i-cherry-pick-only-changes-to-certain-files

Hope this helps!

Please Let me know if you have any queries.

๐ŸŒ
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?

๐ŸŒ
Medium
medium.com โ€บ @mgopal.0001 โ€บ merging-specific-commits-after-a-certain-point-in-git-f59e704027df
Merging Specific Commits After a Certain Point in Git | by Madan gopal | Medium
October 18, 2024 - In such cases, a full merge would bring in unrelated changes, which could clutter your work. Git offers two ways to pull only the commits you need: cherry-picking and rebasing with the --onto option. Cherry-picking is like shopping for specific items in a store โ€” you grab exactly what you need.
๐ŸŒ
Yundingvilla
yundingvilla.com.tw โ€บ intipya โ€บ git-merge-specific-commit
git merge specific commit
October 16, 2024 - # Switch to the "main" branch git checkout main # Cherry-pick the commit from "feature-A" git cherry-pick a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8 # Add the changes and commit them git add . git commit -m "Merged bug fix from feature-A" ... When cherry-picking, you might encounter conflicts if the commit you're cherry-picking introduces changes to the same files that have been modified in your current branch.
๐ŸŒ
JetBrains
youtrack.jetbrains.com โ€บ issue โ€บ IJPL-73962 โ€บ Git-merge-from-any-commit-in-the-Log-list
Git merge from any commit in the Log list : IJPL-73962
{{ (>_<) }} This version of your browser is not supported. Try upgrading to the latest stable version. Something went seriously wrong
๐ŸŒ
DEV Community
dev.to โ€บ bosz โ€บ copy-commit-from-one-branch-to-another-without-using-git-merge-5fp9
Copy commit from one branch to another without using git merge - DEV Community
November 20, 2020 - Yea, could be, not yet explored git that much... ... I signed up at dev.to just to say thanks to you. Thank you for explaining the cherry-pick command in just the right context. ... It gave me an warning after I tried to pull from main: You have not concluded your cherry-pick (CHERRY_PICK_HEAD exists). Please, commit your changes before you merge...
๐ŸŒ
JetBrains
youtrack.jetbrains.com โ€บ issue โ€บ IDEA-185407
Git merge from any commit in the Log list : IDEA-185407
May 4, 2023 - {{ (>_<) }} This version of your browser is not supported. Try upgrading to the latest stable version. Something went seriously wrong
๐ŸŒ
CopyProgramming
copyprogramming.com โ€บ howto โ€บ how-to-merge-a-specific-commit-in-git
A Guide on Merging a Specific Commit in Git
Start to learn software development with many IT tutorials including Python, PHP, Java, NodeJS, MySQL, and MongoDB,... With our easy-to-follow tutorials, you'll be coding in no time!
๐ŸŒ
Tistory
yueliang-front-end.tistory.com โ€บ 23
[git] ํŠน์ • ์ปค๋ฐ‹์„ ๋‹ค๋ฅธ ๋ธŒ๋žœ์น˜์— ๋ณ‘ํ•ฉํ•˜๋Š” ๋ฐฉ๋ฒ• How to Merge a Specific Commit into Another Branch ๐Ÿค”
May 28, 2023 - Firstly, you need to find the commit hash on GitHub, GitLab, or another Git repository. Once you have found it, copy the commit hash. Finally, you need to execute a command. For example, you can use the command "git cherry-pick [commit hash]." This command merges the selected commit into the ...
๐ŸŒ
JetBrains
jetbrains.com โ€บ help โ€บ phpstorm โ€บ apply-changes-from-one-branch-to-another.html
Merge, rebase, or cherry-pick to apply changes | PhpStorm Documentation
April 15, 2026 - It is very common that while you ... referred to as a merge commit that results from combining the changes from your feature branch and main from the point where the two branches diverged....
๐ŸŒ
Delft Stack
delftstack.com โ€บ home โ€บ howto โ€บ git โ€บ git merge specific commit
How to Merge a Specific Commit in Git | Delft Stack
March 11, 2025 - Learn how to merge a specific commit in Git using commands like cherry-pick and rebase. This article provides step-by-step instructions and examples to help you incorporate changes efficiently without merging entire branches. Perfect for developers looking to streamline their workflow and manage their codebase effectively.