Reputation: 2910
I want to maintain two different git repos. The repos should stay in the same root directory. How to achieve it?
What I'm want is: to manage two repositories that differ slightly. Can I have two completely different repositories in the same directory?
Upvotes: 15
Views: 15789
Reputation: 1
I solved this problem, which git doesn't seem to provide a good solution to, by not using git to solve it. I used a directory junction to link a new subfolder to a subfolder of the parent folder (i.e. linking a child folder to an "uncle folder"). Example in Command Prompt for Windows Vista and up:
cd CurrentFolder/
mklink /J "LinkedFolder" "../TargetFolder"
will cause LinkedFolder to point to TargetFolder (note the quotes). Example file structure I would then use:
"POSIX-compliant" operating systems seem to use ln
or ln -s
for this functionality.
It works excellently (note: the following is from my own Windows 8.1 testing):
mklink
See also:
NTFS Junction Point
NTFS Symbolic Link
Symbolic Link
Upvotes: 2
Reputation: 129744
You can achieve this by adding using one of these two options on the git command itself:
git --work-tree=where/my/code/is --git-dir=some/path/to/my/.git status
This would allow you to have 2 separate repos share the same working folder.
However you should be able to get what you need by using one repo with multiple branches and perhaps only push certain branches to multiple remotes.
Upvotes: 13