Is it possible to cherry-pick a commit from another git repository?
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
You'll need to add the other repository as a remote, then fetch its changes. From there you see the commit and you can cherry-pick it.
Like that:
git remote add other https://example.link/repository.gitgit fetch other
Now you have all the information to simply do git cherry-pick
.
More info about working with remotes here: https://git-scm.com/book/en/v2/Git-Basics-Working-with-Remotes
Here's an example of the remote-fetch-merge.
cd /home/you/projectAgit remote add projectB /home/you/projectBgit fetch projectB
Then you can:
git cherry-pick <first_commit>..<last_commit>
or you could even merge the whole branch
git merge projectB/master