Today’s task is getting Xcode working with a remote Git repository, so that I can collaborate with others – and use a laptop and a desktop to program.
- The instructions on github.com are good, and I used them to set up a new username, SSH key, and a repository for a free open-source account.
- I then followed the instructions at “Xcode 4 and Git for newbies“, which are also good. The main things to keep in mind seem to be:
- in Xcode, to set up the repository in the Organizer, you need to press the little plus button at the bottom of the list on the left, and then choose the “Checkout or Clone” drop down – not “add a repository”. The location is email@example.com:<username>/<repository name>.git .
- Save the project as “origin”, which sets up an “origin” directory.
- The password Xcode asks for is the pass phrase used earlier.
- I then created a new Xcode project, and saved it so that it all went into a subdirectory of the origin directory.
- Then committing and pushing the files worked perfectly, and they showed up in my github repository on the web.
The next step was to checkout the repository with the same username but onto a different computer. Trying the naive approach – just opening Xcode and following the same series of steps in the Organizer – led me to the error “Authentication failed because the name or password was incorrect.” The answer was to copy my private and public SSH keys from the first machine to the second, at
~/.ssh/id_rsa*. Note the terminal command “mount” shows the path to any mounted drives, which is helpful for copying. Once copied, I tested the connection to github in the terminal with
ssh -T firstname.lastname@example.org. This informed me I had the wrong permissions for my private key, which I fixed with a chmod. Then I tested the ssh connection as described in the github intro with
ssh -vT email@example.com. This did not work the first time without the “v” flag. For some reason with the “v” it worked, and I was then able to continue in Xcode and connect to the repository.
One other issue when using multiple machines is making sure you export your developer profile from the Xcode Organizer on the original Mac, and import it into the second Mac’s Organizer.
Off to learn about the functional programming language Haskell this evening, to broaden the mind.