My colleague and I work together on an iPhone app in Xcode. Now and then, we want to merge our work. Ideally, this should also work when we are offline and use a USB stick to exchange eachother's projects.
For the case the majority of the changes are non-conflicting, what way can I use to merge these two whole projects locally, and keeping the local GIT repository in sync with these merges?
This is what source control is for. You mention git
, and that's a reasonable source control system to use. git
is very good at branching and merging and makes it pretty easy. You should read the git book chapter on branching. It explains it pretty well.
There are a variety of ways you can do it, but if you both work on different computers, it seems like the easiest way is to have a git
server that hosts the main repository. You can each branch and merge locally or from the server. You shouldn't need to share a memory stick, though you could theoretically keep a local git repository there and each have branches on it. But git was intended to be used by many people distributed in different places each making their own frequent branches and merging them back together.
I should add that you can start a git
repository locally and later move it to a server if you don't have a server right now. You can also use something like github to store your project on a server without having your own server.
To merge the changes into your version, you need to add your colleague's version as a remote repository (although stored locally on harddisk) to your project and then pull the changes from your colleague's project into your own project.
Details:
I'm assuming you have two copies of the same Xcode project, with different changes, on your local harddisk, yours and the one with the additional changes from your colleague that you want to merge into your own version.
Moreover, I'm assuming that both of you use a local GIT repository for local version control. That's the default when you start a new Xcode project, so unsually you don't need to worry about this.
Let's assume the project folders are in these locations:
/Users/UserName/projects/YourVersion
/Users/UserName/projects/YourColleaguesVersion
For adding your colleagues project as a remote repository to your project, do this:
- Go to the Organizer (click in Xcode's Menu: Window > Organizer)
- Click on Repositories at the top of the Organizer window
- Locate YourVersion in the list at the left side of the Organizer window
- Click on "Remotes" under YourVersion
- Click on "Add Remote" at the bottom of the Organizer window
- In the Dialog which appeared, type in this:
- Remote Name:
YourColleaguesVersion
- Location:
file:///Users/UserName/projects/YourColleaguesVersion
- Click the "Create" button and close the Organizer window
Now for pulling the changes from your colleage's project into your project, do this:
- Click in Xcode's Menu: File > Source Control > Pull...
- A Dialog opens and says "Choose remote from which to pull changes." - It should show
YourColleaguesVersion/master
as the remote repository and it should say Remote is online
. Click on the "Choose" button.
- You're done.