Streamline
Streamline

Reputation: 2122

How to handle shared files and folders vis symbolic link within a git repository

I have project I want to store in a git repository and put into github where the substructure of the tree currently has a symbolic link shared folder for common code (contained within the tree - not outside of the tree) between top level folders and the tree.

Example:

.                  - top level project for repo where .git lives
folderA            
  sharedFolder     - real folder
folderB
  sharedFolder -> ../folderA/sharedFolder  - symbolic link folder to avoid duplicate files

Can this be done and how?

I would consider making the content of the sharedFolder its own git repo if that makes for a solution where I can still avoid duplicating code between the content needed in folderA and folderB - if I do that, how would setup the two git repos for this scenario?

Upvotes: 1

Views: 1524

Answers (1)

Ehtesh Choudhury
Ehtesh Choudhury

Reputation: 7790

If you put sharedFolder in its own git repository, you can do git submodule add sharedFolder in each repository that uses it.

For more information, you should look up the git submodule command.

Github has more information about submodules here.

Upvotes: 1

Related Questions