Sharing the same repository between two projects

I'm trying to find out if it's possible to share the same repository between two projects with Git/SourceTree.

I have a two sites with their own repos, both have a plugins folder. Currently, any changes I apply to one plugin, i have to do the same to the plugin on the other site.

I've now created a 3rd repo just for my plugins (i.e. plugFolder1/2/3), I've not included file1.asp, file2.asp, .gitIgnore as they are unique to the site. This structure cannot be changed.

Is it possible to share my plugins repo and pull its content to siteA/B plugins folders. That way I can make changes to my plugins in their receptive site and commit the changes back to the plugins repo for the other sites to pull.

I've looked into submodule and subtree, when I try to add them via SourceTree, I don't understand how I'm able to pull the content from my plugins repo into my site plugins folder.

I have never used any complex stuff within GIT and I don't want to do it wrong. Thank you in advance.


Current setup

 > plugins

 > plugins

Expected setup



1 answer

0 votes


You are on the right track. Personally I would go with Submodules.

You should be able to add you plugins repository as a submodule to your two site repositories. I believe you have already done this.

Submodules store a reference to a particular commit, so they do not automatically update when you independently update the child, plugin , repository.

The way I tend to manage this is to

  • Open each site/parent repository in SourceTree
  • Open the plugin repository in SourceTree
  • Add the plugin/child repository to both parents as a submodule
  • Then add each submodule instance as a new bookmark in SourceTree, naming them in a way that allows you to identify them.

This means you can then work on the submodules semi-independently from the parent, e.g.

  • You can make changes on the canonical local instance of the plugin repository, commit them and push them to the host.
  • You can then open the two submodule instances and pull any changes from the host, this will update the commit reference for the submodule held by the site/parent repository.
  • Commit the submodule change in the site/parent repository.

Hope that makes sense.

Thank you so much for your assistance, it's the most information I've been able to get in the last few weeks. It’s in line with I was attempting to do but I doesn’t seem to work because the destination folder already exists in sitesA/B. 

When I create a submodule in siteA/B, I add the following
Soure path/URL: D:\webapps\testSites\sitePlugins
Local relative path: plugins

I get the following error 
git -c diff.mnemonicprefix=false -c core.quotepath=false -c credential.helper=manager-st submodule add -f D:\webapps\testSites\sitePlugins plugins
'plugins' already exists in the index

As illustrated in my original message


The above repos each already have a folder called plugins and it contains files relevant to the site


Inside the sitePlugin repo I have;

I want to be able to pull the content from PluginRepo into


I hope you're able to advise me how to deal with this situation. 


 I'm sure, I'm not the only one who has come across this scenario before. Am I not explaining/understanding something properly?

Please help!

Is what I'm describing not possible? Can someone please help?

Hi David,

Reading through your response I think the only aproach is to restructure your proects slightly.



With the following respective folders

But split your site plugins repo into 2, one each for pluginfolder1 and plugin folder2, as follows:


Then you should be able to add each as submodules into the \plugins folder of each site.

Effectively running the following on each site repo

git submodule add -f D:\webapps\testSites\sitePlugins\pluginFolder1 plugins\pluginFolder1

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Oct 23, 2018 in Sourcetree

Tip from the team: configure your repos for hosting goodness!

Supported Platforms macOS Windows We recently introduced support for additional hosting services such as GitHub Enterprise, GitLab (Cloud, Community Edition, Enterprise Edition), and...

1,205 views 4 2
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you