tags:

views:

357

answers:

4

Is it possible to have 2 git repositories in one directory? I'd think not, but thought I'd ask. Basically, I'd like to check in my home directory config files (e.g. .emacs) which should be common across all of the machines I work on, but have a second repository for local files (e.g. .emacs.local), which contains machine-specific configurations. The only way I can think of to do that is to have the local config in a subdirectory and ignore that subdirectory from the main git repository. Any other ideas? Thanks!

joe

+5  A: 

Have a look at git submodule.

Submodules allow foreign repositories to be embedded within a dedicated subdirectory of the source tree, always pointed at a particular commit.

Hates_
+1  A: 

Yeah, submodules are probably what you want. Another option would be to have your working copy in a subdirectory and then point symlinks from you home directory to the files of interest.

Pat Notz
+2  A: 

If I understand what you're doing, you can handle it all in one repository, using separate branches for each machine, and a branch containing your common home directory config files.

Initialize the repo and commit the common files to it, perhaps renaming the MASTER branch as Common. Then create a separate branch from there for each machine that you work with, and commit machine-specific files into that branch. Any time that you change your common files, merge the common branch into each of the machine branches and push to your other machines (write a script for that if there are many).

Then on each machine, checkout that machine's branch, which will also include the common config files.

Paul
While submodules will also work, I think this is the best approach for me. The local files will follow a template, and as I make changes to the template on the MASTER branch, I can merge them into the machine local branches, incrementally updating the local config files. Thanks for the help!
Joe Casadonte
A: 

It is possible by using the variable GIT_DIR but has many caveats if you dont know what you are doing.

tzervo