I have a common directory with .h and .cpp files in two different projects. Currently I am manually keeping the two in sync. I do not want to take the directory and create a library, because I don't want my users to have a dependency — I just want to have the two subdirs and their files kept in sync. Is there any simple way to do this?
            Asked
            
        
        
            Active
            
        
            Viewed 168 times
        
    2
            
            
         
    
    
        vy32
        
- 28,461
- 37
- 122
- 246
- 
                    Why not create a third directory that will be your "server" and then you only make changes to those files. Then the other 2 folders(that your projects use) will then always to a git rebase off that folder... Other than making a scheduled task to do the syncing, I think that will be the easiest – Koenyn Nov 26 '12 at 05:35
- 
                    Use a sub-module? One git repository is the master version and the other uses a version of it as a sub-module. – Jonathan Leffler Nov 26 '12 at 05:45
1 Answers
1
            The tow usual solutions are:
- git submodules
- git subtree merging (now easier with the git-subtree.sh script)
The idea is to have your common directory as an upstream independent repo, and to update your directory in your different project by:
- updating your submodule
- git subtree pull -P <prefix> <repository> <refspec...>
Considering how submodules can be tricky, in your case I would recommend the git-subtree script.
 
    