title: Sharing the same file between different projects
body: <p>For version control we currently use Visual Source Safe and are thinking of migrating to another version control system (SVN, Mercurial, Git).</p>
  
  <p>Currently we use Visual Source Safe's "Shared" file feature quite heavily. This allows us to share code between design and runtimes of a single product, and between multiple products as well.</p>
  
  <p>For example:</p>
  
  <pre><code>**Product One**
    - Design
       Login.cpp
       Login.h
       Helper.cpp
       Helper.h
    - Runtime
       Login.cpp
       Login.h
       Helper.cpp
       Helper.h
  
  **Product Two**
    - Design
       Login.cpp
       Login.h
    - Launcher
       Login.cpp
       Login.h
    - Runtime
       Login.cpp
       Login.h
  </code></pre>
  
  <p>In this example Login.cpp and Login.h contain common code that all of our projects need, Helper.cpp and Helper.h is only used in Product One. In Visual Source Safe they are shared between the specific projects, which means that whenever the files are updated in one project they are updated in any project they are shared with.</p>
  
  <p>This is a simple example but hopefully it explains why we use the shared feature: to reduce the amount of duplicated code and ensure that when a bug is fixed all projects automatically have access to the new fixed code.</p>
  
  <p>After researching alternatives to Visual Source Safe it seems that most version control systems do not have the idea of shared files, instead they seem to use the idea of sub repositories. ( <a href="https://www.mercurial-scm.org/wiki/subrepos" rel="nofollow noreferrer">https://www.mercurial-scm.org/wiki/subrepos</a> <a href="http://svnbook.red-bean.com/en/1.0/ch07s03.html" rel="nofollow noreferrer">http://svnbook.red-bean.com/en/1.0/ch07s03.html</a>)</p>
  
  <p>My question (after all of that) is about what the best practices for achieving this are using other version control systems?</p>
  
  <ol>
  <li><p>Should we restructure our projects so that two copies of the files do not exist and an include directory is used instead? e.g.</p>
  
  <p><strong>Product One</strong></p>
  
  <ul>
  <li>Design
   Login.cpp
   Login.h</li>
  <li>Runtime
   Login.cpp
   Login.h</li>
  <li>Common
   Helper.cpp
   Helper.h</li>
  </ul></li>
  </ol>
  
  <p>This still leaves what to do with Login.cpp and Logon.h</p>
  
  <ol start="2">
  <li><p>Should the shared files be moved to their own repository and then compiled into a lib or dll? This would make bug fixing more time consuming as the lib projects would have to be edited and then rebuilt.</p></li>
  <li><p>Should we use externals or sub repositories?</p></li>
  <li><p>Should we combine our projects (i.e. runtime, design, and launcher) into one large project?</p></li>
  </ol>
  
  <p>Any help would be appreciated. We have the feeling that our project design has evolved based on the tools that we used and now that we are thinking of switching tools it's difficult for us to see how we can best modify our practices. </p>
  
  <p>Or maybe we are the only people are there doing this...?</p>
  
  <p>Also, we use Visual Studio for all of our stuff.</p>
  
  <p>Thanks.</p>