简体   繁体   English

iOS多个项目和git分支

[英]iOS multiple projects and git branches

Im not an expert at git, but I have a iOS project that has code that I would like to reuse. 我不是git的专家,但我有一个iOS项目,其中包含我想要重用的代码。 I will be switching out images and a little data to make each application different. 我将切换图像和一些数据,以使每个应用程序不同。 I know you can do this with the targets approach but I wanted to keep everything seperate and out of the original xcode project. 我知道你可以用目标方法做到这一点,但我想保持一切独立和原始的xcode项目。 So my question is, do I create a branch for each new project, and if so what is the correct terminology or command to grab bug updates from the original code base into my new branch from the main branch? 所以我的问题是,我是否为每个新项目创建了一个分支,如果是这样,从主分支中获取从原始代码库到新分支的错误更新的正确术语或命令是什么? The new branch will never commit back to the master branch also. 新分支也永远不会回到主分支。

I strongly suggest you make different repository for each project, not different branch. 我强烈建议你为每个项目制作不同的存储库,而不是不同的分支。 If you have one repository for several projects and for each project different branch, very soon you'll have a mess in your repo. 如果你有几个项目的存储库和每个项目不同的分支,很快就会在你的回购中乱七八糟。

Also, if you fix a bug on part of code which you want to reuse, you'll need to merge the fix with all branches which use that code. 此外,如果您修复了要重用的部分代码的错误,则需要将修复程序与使用该代码的所有分支合并。

So, I think the better and much cleaner approach would be to create different repositories for each project, and code which you want to reuse you can add as a git submodule . 因此,我认为更好更清洁的方法是为每个项目创建不同的存储库,并且您想要重用的代码可以添加为git子模块

So, you'll have repository for your iPhone project then submodule for your shared library, Restkit, and so on... 因此,您将拥有iPhone项目的存储库,然后是共享库,Restkit等的子模块......

You will want to review the git branching section of the online reference at GIT-SCM . 您需要查看GIT-SCM在线参考的git分支部分。 At a high level you will want to look at merging the various branches. 在高级别,您将希望看到合并各个分支。 Xcode 5/5.0.1 helps you immensely by using the menu Source Control > Working Copy > Project Name > New, Switch, or Select Merge Into/From Options... Xcode 5 / 5.0.1通过使用菜单Source Control> Working Copy> Project Name> New,Switch或Select Merge Into / From Options帮助您获得极大的帮助...

合并选项

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM