I have two apps/projects - one for customers and one for workers. Both projects have the same back-end API related code, the same business-level objects, the same custom GUI controls and some functionality. I want to replace the identical code with the shared one. For example to move this code to a separate repo.
Since both projects are under development everything (including shared code) will be changed very often. Shared code will be usually updated as a part of one of these two projects.
What is the best way to share the code between two projects if I need an easy way to frequently update it?
My ideal use case will be the following:
I change the customer project (customer and shared code).
I commit and push new changes to the customer repo and to the shared code repo.
I open worker project, do pull for the shared code and then update worker code if it needs to reflect shared code changes.
P.S. Qestions Differences between git submodule and subtree and GIT Nested repositories: Composer vs. SubModules vs. Subtree vs.? have very good answers but it is still not clear what should I choose if I need an easy way to frequently update shared code.
I would use a git submodule personally, it's a very good link to a shared codebase that is itself a git repository that can be managed separately without being tracked in your other projects.
You can use git submodule foreach git pull origin master on both the client and worker side to pull in changes when the shared library is updated.
Related
I have an Xcode project and I have to share it with other developers. They have to work on a small part of this, and compile.
I started trying to convert a lot of code as framework, but it was beginning to be complex because of a lot of interweaving of #import.
Is possibile make project with some .o file e some that have to be build?
I'm open for any another way
NB: I forgot something fundamental: I want build some part of project because I don't want to permit to see how it is implemented
You can put it to github as a free, open repository, or make it private, but have to pay. Then necessary part of it can be linked as a submodule.
It's possible without a github also, if you have some centralized place, where you can put it.
You can separate the code you want them to work on and create a git submodule. They can then clone and work on the git submodule and push their work to the repo as they progress. You can then keep pulling their changes on that submodule.
Check these resources
Git Submodules: Adding, Using, Removing, Updating
Git Tools - Submodules
Essentially you will split your project into sub projects (doesnt need to be a new xcode project if there is no need for specific build settings) and track them as submodules in git.
So the scenario would be
Determining the code they must work on or the sub "project"
Create a submodule from that code (move the code to a folder in your project directory and initialize the submodule)
Push the submodule to your repo, e.g. github/bitbucket
Developers would pull down your submodule into their existing xcode project.
The submodule will contain only classes and files etc. that they need. All changes that they make to the submodule will be tracked and you can pull them and have continuous integration (some form).
We are going to be migrating an existing BizTalk codebase into TFS 2015 update 2. We would like to use GIT rather than TFVC for version control.
I have a problem getting my head around the repo to project relationship. I would like to run independent TFS projects for managing discrete pieces of work that align with "projects" as run by the business. Instinct tells me that I should create a branch for such projects but each TFS project seems to need its own repo?
If I stick with a single (BizTalk) TFS project, I will be able to create a branch for each business project but the work items will all be mixed together. This would make helpful reporting tools such as the burndown chart useless.
I guess the other option is to run multiple TFS projects each with their own repo and then manually merges between the repos? Maybe have a "Main" project and use its repo as the main branch of the project repos?
How are people managing this problem?
First note that inside a Team Project you can create several Git repositories.
Also, remember that Git branches have repository scope, it is not a directory like in TFVC (which it is not like Git at all :-) ).
Then if you want to migrate to Git, you need to modularize your projects. Once you have a modular code base, for each module you should create a Git repository. From each repository you should be able to build and publish a Nuget package. Then resolve inter module dependencies by resolving dependencies by means of Nuget package.
No need to merge anything from repo to repo or from module to module :-) You only need to merge from branch to branch inside the same repository.
The better way is that you can create multiple repositories in GIT Team Project.
Regarding work items, you may create multiple teams and areas, then put work items in different areas and change area per to requirements (the teams can have the same area).
There is a blog that may benefit you: Many Git Repositories, but one Team Project to rule them all
I have an ios standalone project managed with git in a git repository.
With this code, I am creating an ios dynamic library which will have some slight modifications from the standalone code to make it work as a library.
Now I have to manage two different code bases and whenever I make a change in the standalone project, sometimes I miss the changes in the dynamic library.
Is it possible to manage the common code in the standalone project and dynamic library from a common repository or what is the right way to do this?
I need to maintain standalone project separately because I cannot run and debug the framework easily as the standalone project.
If the standalone project can live in a subfolder of the dynamic library project, then you can use git submodule to reference a SHA1 of the first project into the second one.
git submodule add git#github.com:AFNetworking/AFNetworking.git Vendor/AFNetworking
Each time you modify anything in that subfolder, you can commit and push as usual, but also go back to your main project (the dynamic one), add, commit and push to record the new SHA1 of your submodule.
The other approach would be to use a subtree (as illustrated here, see tutorial).
git subtree add --prefix=Vendor/AFNetworking --squash git#github.com:AFNetworking/AFNetworking.git master
I prefer the first approach, but you can see both used in the context of a IOS project in this article
The scenario is as follows. I am working at a company that started out with one iOS application. Now, the company is interested in creating a second iOS application, that shares much of the same code base. The original application was not written with the intention of being reusable, as it was not known at the time that a second similar application would be created. In future, there may be even more similar applications that build on the existing code base.
We are trying to determine the "best" option with respect to how we maintain the source code going forward. So some of the options we're contemplating include single repository with shared library, one repository for shared library and one repository that contains all of the iOS applications, one repository for shared library and one repository per iOS application, etc etc. There's also the question of whether to use git submodules or not if using multiple repositories etcetera.
Currently, the two applications + library are all in one git repository. One of the advantages of this is that a developer can checkout a commit of the single repository and expect the product to build, without having to worry about updating multiple repositories. Basically, the developer doesn't have to be concerned with multiple repositories needing to move in lockstep with one another or requiring some specific combination of repositories commits for a build to work. The developer also doesn't have to worry about cases where another developer may have remembered to commit one repository, but not the other.
Here are some more things I've considered:
Submodules
I've used submodules before, but am no expert. My understanding is that the "super" repository containing a submodule also stores a reference to a specific commit of the submodule. This partly deals with ensuring that multiple repositories (i.e. application + library) would move in lockstep, though I'm guessing there are still issues with needing to manually pull changes from the sub module. Also, issues with a submodule commit not being available to pull if a developer happens to forget to push its changes and it is referred to by the super repository.
One nice aspect of submodules is that it creates a stronger semantic separation between the library and the applications which happen to use the library. Whether this is useful in practice, I'm not sure.
Single repository
As previously stated, this is what we're currently doing. Two applications + shared library code all in one repository. The greatest concern has been around the relatively non-existent ability to isolate changes between project one and two and the library. E.g. someone makes changes to both some library code and some application code in a single commit. Then, another developer just wants the changes in the library code.
One nice aspect of single repository is that everything moves in lockstep - nobody has to worry about keeping multiple repository versions matched. If using XCode workspaces, refactorings are even possible across the two applications.
Branching
Another option is to use some kind of branching model, either in a single or multiple repositories, to manage the code.
Ultimately, we're just trying to figure out a good model going forward for managing two or more iOS applications plus shared library code. Whether this be achieved via multiple repositories, submodules, branching models, or something else. Any general suggestions on the pros and cons of the various options?
Use submodules. You don't need to be an expert because they are really easy to use. Especially when combined with a GUI like SourceTree. I had the exact same scenario as you and that is what I did. SourceTree will even warn you if you are trying to commit a repo that has uncommited changes in a submodule.
A single repository is ludicrous. That would mean that every time someone new wanted to download a project, they would have to download them all.
Branching is going to turn out to be too complicated with making bug fixes that apply to all relevant branches.
The structure I have for my current project is:
Project repo (For the project I am personally working on)
-Project base repo (For shared code between team members)
--Utilities repo (For code that is reusable in any project)
Cocoapods, they make managing related code between applications simple.
We had a similar base for a suite of apps and initially it was a huge pain to manage but once you get custom cocoapods running you will never look back. You should check out this for a starting guide on managing your own cocoapods.
It's free, it's powerful and you will wonder why you never used them sooner.
I have a Rails website which has been divided into two separate projects - the public site, and the administration site.
As both sites are using the same database the models are shared between the applications (actually right now they are duplicated). The problem I have here is that when an update to the models occurs in the public project I need to copy the changes over into the admin project.
I've had a look around SO and noticed that there was a question which had answers suggesting using svn:external or git submodule, but I'm not entirely sure how to do this.
Essentially my aim is to be able to make the changes in one place only, commit those changes to git and then be able to pull the changes in the other project when I need to update that as well.
You need to:
commit the submodule in one place
commit the main project (said the public site)
go to the same submodule in the other main project (the admin site)
pulling the latest content (changing the HEAD of that submodule)
going one directory up in the main (admin) project
commit (to record that you now reference a different version of the submodule)
See also true nature of submodules.
Do not use submodules. They are ugly, hard to understand and to maintain. Much better is to use subtrees.
Git subtree is a part of GIT since 1.7.11 and I wrote an article about sharing code between Rails applications: http://igor-alexandrov.github.com/blog/2013/03/28/using-git-subtree-to-share-code-between-rails-applications/
In short: yes git-subtree works and works great!