The answer, as given, is to use format-patch but since the question was how to cherry-pick from another folder, here is a piece of code to do just that:

$ git --git-dir=../<some_other_repo>/.git \
format-patch -k -1 --stdout <commit SHA> | \
git am -3 -k

Explanation from Cong Ma comment Aug 28 '14

git format-patch command creates a patch from some_other_repo's commit specified by its SHA (-1 for one single commit alone). This patch is piped to git am, which applies the patch locally (-3 means trying the three-way merge if the patch fails to apply cleanly).

Answer from Robert Wahler on Stack Overflow
🌐
Graphite
graphite.com › guides › git-cherry-pick-other-repo
How to cherry-pick commits from another repository in Git
Replace <repository-url> with the URL of the Git repository from which you want to cherry-pick the commit. This adds a copy of the selected repository to your local machine. If you already have a local repository and just need to access a commit ...
Discussions

?use cherry-pick to copy a file to another repo, preserving commit history?
That looks like a ChatGPT hallucination. A cherry-pick will not even bring over the history of a file on the same repository, much less to another repository. There is -x in the command which will amend the commit message to say which commit it comes from, but it's just that, git log won't follow that. There are multiple things you can do depending on how comfortable you are with git and how badly you really want the history of the file: git merge with unrelated histories is an option, but that will be for the entire repository, not just one file git filter-branch can be used to rewrite the history to only keep a single file and then merge that over. The history is preserved but the commit hashes will change. you could manually copy the file and in the commit message mention where it comes from (repo url and commit hash). That's similar to cherry-pick with -x you could add the repo as a submodule when copying the file to have a more explicit record or where it came from, and maybe even delete the submodule afterwards if it's not needed you could use git replace to graft the repositories together but that's probably overkill and will require people to to know they have to fetch the replace refspec More on reddit.com
🌐 r/git
2
0
March 28, 2024
Can I cherry pick from a repository/project with a different folder structure?
cd project1 && git format-patch commit1..commit2 cd project2 && patch -p3 0001-Blah-blah-blah.patch More on reddit.com
🌐 r/git
3
11
November 3, 2014
Our team has been forced into using git cherry-pick in order to promote changes to other environments, and it's not going well, any alternatives?
Ah, nothing like bosses freaking out and inviting clueless people to make things worse without ever addressing the root problem. Your merge based system was the right way to do this. The correct solution to the original problem is to stop letting third party devs promote code if they aren't adhering to standards. One of the biggest problems in our industry is how we refuse to address people problems and instead throw janky technical bandaids at them. We don't allow cherry picking because the code will exist in multiple commits with different hashes when branches are merged. More on reddit.com
🌐 r/devops
68
127
March 20, 2024
How to copy commits from one branch to another?

Don't copy anything. There are a few ways to achieve this:

  1. Rebase experiment onto dev. This will "move" experiment so that it "starts" where dev currently is; that is to say, it will put the entire dev branch in the history of experiment. Then you can test, and if everything works ok you can merge experiment into dev.

  2. Merge dev into experiment. Test. When everything is ok, merge experiment into dev.

More on reddit.com
🌐 r/git
3
1
September 19, 2019
🌐
Reddit
reddit.com › r/git › ?use cherry-pick to copy a file to another repo, preserving commit history?
r/git on Reddit: ?use cherry-pick to copy a file to another repo, preserving commit history?
March 28, 2024 -

EDIT: Ignore this question, and move there, where I rephrased the problem in better way -> https://www.reddit.com/r/git/comments/1bq5mv6/how_to_move_file_with_commit_history_to_another/

PROBLEM X: move file to another repo preserving its commit history
I did it once successfully within the repo and into another repo, but git mv doesn't work when I'm trying to move to another repo.

PROBLEM Y: solve merging conflict in cherry-picking method (guess it's a wrong method to solve X)

I want to move a file from one repo to another without losing its commit history. I tried git mv and got sth like: no, because destination path is outside of the repository. Chat GPT told me to use cherry-pick.

  1. git remote add source <source_repository_url>

  2. git fetch source

  3. git cherry-pick <commit_hash> Cherry-pick the File: Cherry-pick the commit that introduced the file you want to move from the source repository.

  4. Remove the File from the Source Repository (Optional): If you want to remove the file from the source repository after moving it, you can push a deletion commit. git push source :<branch_name>

  5. In another response, there just 1., 2. and the 3. step is: git checkout source/main -- path/to/file

There is some conflict. What was fetched cannot be merged due to this conflict. But I don't know where it is, because not between the state of file and the commit hash - it's the latest change and in both repos everything is up to date. If it's a conflict between the sourced repo and the destination repo it's correct, because I don't wanna clone. I want to move or copy just one file with its commit history.

I didn't use cherry-pick before and I will now start reading about it, but I predict the battle is lost.

🌐
DEV Community
dev.to › jmalvarez › how-to-cherry-pick-a-commit-from-another-repository-4pf1
How to cherry-pick a commit from another repository - DEV Community
October 11, 2022 - Now that you are tracking the other repository and have fetched the changes you can list the commits of a specific branch and cherry-pick a commit. git log otherRepo/<branch> git cherry-pick <commit>
🌐
GitKraken
gitkraken.com › home › learn › problems & solutions › can you cherry pick from another repository in git?
Can you cherry pick from another repo? | Solutions to Git Problems
August 5, 2022 - It is possible to cherry pick from another repo using the command line. You will first need to add the other repository as a remote and then fetch the changes. From there, you should be able to see the commit in your repo and cherry pick it.
🌐
TheServerSide
theserverside.com › blog › Coffee-Talk-Java-News-Stories-and-Opinions › How-to-git-cherry-pick-from-another-branch-to-your-own
How to 'git cherry-pick' from another branch example
Since the repo was just initialized, all of this will occur on the master branch. /c/ git cherry-pick example (master) $ echo 'abba' > abba.html $ git add . | git commit -m '1st commit: 1 file' $ echo 'bowie' > bowie.html $ git add . | git commit -m '2nd commit: 2 files' $ echo 'chilliwack' > chilliwack.html $ git add . | git commit -m '3rd commit: 3 files' We are about to git cherry-pick from another branch, and specifically, we will be pulling in the second commit, but before we do we will delete all of these files and perform a commit to put the master branch back into an empty state.
🌐
DEV Community
dev.to › mayallo › two-ways-to-git-cherry-pick-from-another-repo-5m5
Two Ways To Git Cherry-Pick From Another Repo - DEV Community
October 2, 2025 - If you already have a remote with that name, pick a different alias. ... This will bring all branches and commits from RepoB, so that your local Git can see them. You can now reference branches like repoB/main or repoB/feature-xyz. ... You need the commit hash (SHA) you want to cherry-pick.
Find elsewhere
🌐
Elliot Blackburn
elliotblackburn.com › cherry-pick-git-commit-across-repository
Moving a git commit from one repository to another
December 10, 2018 - git checkout -b new-proj-master --track new-proj/master · This will create a new local branch called new-proj-master which is tracking the remote master branch. You might see some pretty drastic changes to your working tree from this, that's because you've basically just checked out a new repository. Now we can simply cherry-pick commits from any other branch in our repository over to this branch and then push the changes up to the new-proj remote.
🌐
Mayallo
mayallo.com › home › shorts › two ways to git cherry-pick from another repo
Two Ways To Git Cherry-Pick From Another Repo | Mayallo
October 2, 2025 - If you already have a remote with that name, pick a different alias. ... This will bring all branches and commits from RepoB, so that your local Git can see them. You can now reference branches like repoB/main or repoB/feature-xyz. ... You need the commit hash (SHA) you want to cherry-pick.
🌐
Nasiothemes
nasiothemes.com › how-to-cherry-pick-a-commit-from-one-repository-to-another-in-git
How to Cherry Pick a Commit from One Repository to Another in Git – Nasio Themes
Step 1: Add a Remote to the Source Repository: In your target repository (RepoB), the one where you want to cherry pick the commit you have done, you need to add a remote reference to the source repository (RepoA). This remote reference will allow you to fetch all the commits from the source ...
🌐
Atlassian
atlassian.com › git › tutorials › cherry pick
Git Cherry Pick | Atlassian Git Tutorial
December 15, 2025 - git cherry-pick is a powerful command that enables arbitrary Git commits to be picked by reference and appended to the current working HEAD. Cherry picking is the act of picking a commit from a branch and applying it to another. git cherry-pick ...
🌐
Coderwall
coderwall.com › p › sgpksw › git-cherry-pick-from-another-repository
Git cherry-pick from another repository (Example)
November 19, 2020 - #cherry-pick · #git · Let's say you want to apply some patches from someone else repository: # Cloning our fork $ git clone git clone git@github.com:ifad/rest-client.git # Adding (as "endel") the repo from we want to cherry-pick $ git remote add endel git://github.com/endel/rest-client.git # Fetch their branches $ git fetch endel # List their commits $ git log endel/master # Cherry-pick the commit we need $ git cherry-pick 97fedac # Pushing to our master $ git push origin master ·
🌐
tech.serhatteker.com
tech.serhatteker.com › post › 2022-08 › git-cherry-pick-another-repo
Git cherry-pick From Another Repository — tech.serhatteker.com
August 18, 2022 - $ cd your-project $ git checkout your-branch # or use switch if you have git >= 2.23.0 # $ git switch your-branch · Add the desired commit repository as a new remote that you want to cherry-pick from.
🌐
Medium
medium.com › @satorusasozaki › move-all-commits-to-another-repository-2a3506ca3ed5
Move all commits to another repository | by Satoru Sasozaki | Medium
May 27, 2020 - [git rebase -i] Squash all the commits that you have made so far in your old repository into one commit so that it will be moved more easily. [git cherry-pick] Take the squashed commit from the old repository and merge it to the new forked repository
🌐
Git Scripts
gitscripts.com › git-cherry-pick-from-another-repo
Git Cherry Pick From Another Repo: A Quick Guide
September 3, 2024 - Cross-repo cherry-picking means selecting commits from one repository while working in another. It’s crucial to understand how different repositories can have different configurations and setups.
🌐
Boot.dev
boot.dev › blog › devops › git cherry-pick: copy one commit to another branch
Git Cherry-Pick: Copy One Commit to Another Branch | Boot.dev
1 month ago - There comes a time in every developer's ... git cherry-pick solves this: it takes a single commit from anywhere in your repo and applies it to your current branch, no full merge required....
🌐
Medium
medium.com › @yacobusr › git-cherry-pick-from-another-repository-2f04d915b117
Git cherry-pick from another repository | by Yacobus Reinhart | Medium
October 6, 2017 - # Cloning our fork $ git clone git clone git@github.com:ifad/rest-client.git# Adding (as "endel") the repo from we want to cherry-pick $ git remote add endel git://github.com/endel/rest-client.git# Fetch their branches $ git fetch endel# List their commits $ git log endel/master# Cherry-pick the commit we need $ git cherry-pick 97fedac# Pushing to our master $ git push origin master
🌐
Graphite
graphite.com › guides › git-cherry-pick-from-another-branch
Git cherry-pick file from another branch
Here’s how to cherry-pick individual files or folders from one branch to another: First, you need to identify the specific commit from which you want to cherry-pick files. You can find the commit by looking at the Git log of the branch containing the desired changes. ... Look through the output to find the commit hash of the changes you want to cherry-pick. Each Git commit hash is a unique identifier generated by Git to represent a specific commit in a repository.
🌐
Faun
faun.pub › git-cherry-pick-a-commit-to-another-repo-30dc64d61acb
Git cherry pick a commit to another repo | by Omar ELFarsaoui | FAUN.dev() 🐾
April 14, 2023 - You can switch to the correct branch and cherry-pick the commit to where it should belong. ... Let’s assume that we have two repositories A and B, in repo A we have a commit with few changes and we want to move them to the repo B. Join Medium for free to get updates from this writer. ... First thing let’s add a new origin to the repo B. $ cd repo-B $ git remote add repo-A git@github.com:elfarsaouiomar/repo-A.git