Search code examples
gitgithubgit-remote

Track project's particular local folder with remote branch's particular folder


I want to connect one particular folder of local repo to remote repo's particular folder on github.com

Sample local and remote structure of my project. (CodeIgniter/PHP structure for example)

My local Repo structure =>

C:\wamp64\www\myproject\
    admincp
        assests_admin
        index.php
    application
        admincp
            config
            controllers
            models
            views
        front
            config
            controllers
            models
            views
        language
    assests_front
    uploads
    userfiles
    vendor
    index.php

My Git Remote Repo structure (Private Repo) => In remote repo, I have just following folders.

Also I have just master branch here.

https://github.com/username/myproject/
    assests_admin
    admincp
        config
        controllers
        models
        views
    assests_front
    front
        config
        controllers
        models
        views

Now I want to track local C:\wamp64\www\myproject\application\admincp folder (with all it's subfolders and files) with remote repo https://github.com/username/myproject/admincp folder and it's all contents.

Same as track local C:\wamp64\www\myproject\application\front folder (with all it's subfolders and files) with remote repo https://github.com/username/myproject/front folder and it's all contents.

Que 1=> Is this type of scenario possible?

Que 2=> If possible then, In which local folder's I have to run $git init commands to achieve above scenario? After that which config and remote add commands to run? Please let me know the complete procedure.

Thanks in advance.


Solution

  • Assuming admincp is a local Git repository (meaning you have made git init . in that folder, add and commit), you could:

    • push admincp to its own GitHub repository
    • reference that repository in your myproject parent GitHub repo, with admincp as a submodule.