TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Can I have multiple Git repos from a single project folder?

6 pointsby circuitbreakerover 14 years ago
I have a project that I want to maintain in Git. It is a web-project that I develop in Eclipse. Essentially, there are two components:<p><pre><code> 1) the main service engine (i.e. the Java code) 2) the web-files (i.e. the HTML, JSP, CSS, and JS files). </code></pre> I'd like to maintain this all with Git but I'd like to have distinct repos for each component of the site. So, is there a way to have multiple repos from this single project folder? More specifically, is it possible to have multiple files from a single folder belong to different repos?

2 comments

timtadhover 14 years ago
if you want the files interleaved in the same folder hierarchy (ie. not separated into engine and web-files as @shorbaji suggests) to my knowledge there is no way to do this. I doubt any folder based version control system will allow you to do that. You would have to use something like RCS :shudder:<p>If you are considering such a structure, ask your self: why? This is not a common structure (thus the lack of tool support), but your problem is common.<p>If you want to separate your files into two subdirectories as suggested, I recommend using a top level git repo to track all of it, and using git submodule for your engine:<p><pre><code> projects | engine # directory containing you engine code | .git | files... | MyProject | .git | .gitmodules | engine # a clone of your engine repository above | ... | the rest of your files ... </code></pre> If you don't know how git submodule works, read the man pages.
评论 #1997987 未加载
shorbajiover 14 years ago
If you have these components in separate folders within the main project folder simple create a git repo within each folder.<p><pre><code> $cd engine $git init . $cd ../web-files $git init . </code></pre> If you have one folder within the other, you can do the same but use .gitignore