Manage project backend and frontend in two separate branches or repositories?

限于喜欢 提交于 2019-12-21 18:00:13

问题


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.

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?


回答1:


TL;DR

should I probably have 2 separate repositories for the server and for the app?

Yes, that's the right way.

Details.

A branch usually tracks a state of the whole working tree (that's a name for everything in the folder under Git control).

This is NOT possible to have in working tree with one repository and two branches:
myapp_server version a AND myapp version b

Only this is possible:
myapp_server version a OR myapp version b

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.




回答2:


The real question here is not if it's possible to hack git to achieve this (the answer is yes) but rather why would you like to do that. What would such worklow allow you to do? Moreover there is nothing wrong with 2 separate repositories for each component.

Btw branch is just a pointer to the commit, which means that yes, you can have completelly unrelated branches in git repository.



来源:https://stackoverflow.com/questions/30628356/manage-project-backend-and-frontend-in-two-separate-branches-or-repositories

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!