Steps used:
1) Create a new local branch of the source repo (A) and switch to it (branchOnRepoA).
2) Filter the directories that you want to keep from A using git-filter-repo. This will rewrite history. It should de downloaded first from https://github.com/newren/git-filter-repo
python3 git-filter-repo --force --path src/main/resources/folder1 --path src/main/resources/folder2
3) In destination repo (B) we should add A as a remote source repo
git remote add source C:\repoA
source - remote repo name C:\repoA - path to the remote source repo
4) From B import data from A:
git fetch source
5) From B, merge A branch:
git merge source/branchOnRepoA --allow-unrelated-histories
6) From B, remove A:
git remote remove source
7) From B, push changes:
git push "origin" main:main
8) Clean-up local branch created in step 1).