在两个单独的分支或存储库中管理项目后端和前端? [英] Manage project backend and frontend in two separate branches or repositories?
问题描述
我开始了一个移动应用程序的项目,该项目将具有服务器端和应用程序本身.因此,在master
分支中,我创建了2个项目myapp_server
和myapp
,然后又创建了2个其他分支backend
和frontend
,我只想将与它们相对应的项目文件推送到单独的分支中.但是,f.e.在backend
分支中,我只想放置项目文件,而没有父文件夹myapp_server
本身.我应该为该项目文件夹内的单独分支创建git init
吗?我只在包含master分支的两个项目的目录中创建了git init
.
I started a project of a mobile app that will have a server-side and the app itself. So, in the master
branch I created 2 projects myapp_server
and myapp
and then I created 2 other branches backend
and frontend
and I want to push to the separate branches only the project files corresponding to them. But, f.e. in the backend
branch, I want to put the project files only, without the parent folder myapp_server
itself. Shall I make a git init
for the separate branch inside of this project folder? I've made git init
only in the directory that contains both projects for the master branch.
由于我在这里有点困惑,我该怎么办呢?那可行吗?这是一个坏主意,我可能应该为服务器和应用程序提供2个单独的存储库吗?
How can I actually do that, because I am a bit confused here? Is that even feasible? Is it a bad idea and should I probably have 2 separate repositories for the server and for the app?
推荐答案
TL; DR
我应该为服务器和应用程序提供2个单独的存储库吗?
should I probably have 2 separate repositories for the server and for the app?
是的,这是正确的方法.
Yes, that's the right way.
分支通常跟踪整个工作树的状态(这是Git控制下的文件夹中所有内容的名称).
A branch usually tracks a state of the whole working tree (that's a name for everything in the folder under Git control).
这不可能在具有一个存储库和两个分支的工作树中进行:
myapp_server version a
和myapp version b
This is NOT possible to have in working tree with one repository and two branches:
myapp_server version a
AND myapp version b
这仅是可能的:
myapp_server version a
或myapp version b
Only this is possible:
myapp_server version a
OR myapp version b
您拥有的每个项目都应拥有自己的Git存储库.这可以是独立存储库,也可以是git 子模块一个>.子模块是一个非常复杂的概念,对于这种情况来说是一个过大的杀伤力.
Every project that you have deserves it's own Git repository. This may be either a stand-alone repository or a git submodule. Submodules are quite a complex concept, and an overkill for this situation.
这篇关于在两个单独的分支或存储库中管理项目后端和前端?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!