0

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?

peikado
  • 75
  • 1
  • 8
  • [Pushing Code to Two Remotes](https://stackoverflow.com/q/14290113/2550406), [How can I push/pull from multiple remote locations](https://stackoverflow.com/questions/849308/how-can-i-pull-push-from-multiple-remote-locations) – lucidbrot Feb 01 '22 at 13:38
  • I think you don't need two repositories to accomplish that, making things a lot easier too. With multiple repositories, there is always something that needs to manually synced, there is no automation for that, especially when merge conflicts happen. – Daniel W. Feb 01 '22 at 13:39
  • Also consider: [git submodules](https://git-scm.com/book/en/v2/Git-Tools-Submodules) – lucidbrot Feb 01 '22 at 13:40
  • @DanielW. The reason why I have done repo A as a separate repository is that I don't want repo B to be cluttered with all the relatively large folders of repo A, while I can simply have the minified 'dist' folder for it. But yes, if I don't have a choice, I'll have to merge the repositories, as I planned it before knowing about modification. Thank you! – peikado Feb 01 '22 at 14:03
  • 1
    A way cleaner solution would be to make use of github releases and artifacts. So you have one repo with the full source and another place with only the dist things. No need to have two repos with full source. – Daniel W. Feb 01 '22 at 14:07

0 Answers0