2

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?

vy32
  • 24,271
  • 30
  • 100
  • 197
  • 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 Answers1

1

The tow usual solutions are:

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.

Community
  • 1
  • 1
VonC
  • 1,042,979
  • 435
  • 3,649
  • 4,283