Tom
Tom

Reputation: 845

Git linked directory (always in sync)

I'm using GitHub to host two repos, they both contain a directory named "lib", this directory is exactly the same in both repos. At the minute every time I modify the contents of the "lib" directory in one of the repos, I have to copy and paste the newly modified "lib" directory to the other repo then push it to GitHub. I was just wondering if their was a better way to do this, where the "lib" directory is only in one repo and somehow linked inside the other repo so I only have to modify the contents of the "lib" directory once and they are always both in sync with each other.

Upvotes: 1

Views: 64

Answers (3)

Ben
Ben

Reputation: 679

Depending what you have in lib it might be worth extracting the shared files out into their own repo, and using a dependency manager like bower or bundler to keep each project on the correct version.

Upvotes: 1

Adam Spiers
Adam Spiers

Reputation: 17916

Git submodules are often awkward to deal with. You may well be better off using git-subtree. Just like with git submodules, this would require a separate repo which contains the contents of the lib directory, and then you use git subtree to synchronise changes between this and the other two repos.

Upvotes: 0

Lajos Veres
Lajos Veres

Reputation: 13725

You should create a submodule from this directory. http://git-scm.com/book/en/Git-Tools-Submodules

Upvotes: 0

Related Questions