I have two different repositories in my GitHub account, say A and B. Both A and B are cloned in the same folder on my desktop, say MAIN. Now, I need a copy of a specific folder that is in repo A to be in repo B and to be in sync with each other. That is, when I commit and push a change to that folder in repo A, I wish the copy in repo B also gets updated on github.com and I don't care if the folder in repo B also gets updated on my desktop, as I don't work much on that folder in my local.
I want this mainly because I have a code repository for a simple website and a minified 'dist' folder of it in the repo A. Repo B is a github.io page, where I need the 'dist' folder of repo A to be a web page in it.
I know that this can be done manually by copy-pasting and replacing the folders and committing them individually. But, is there an automated way to do this? Also if possible, will the history of the folder in repo A get preserved in repo B too?