Yesterday, I posted a question on how to clone a Git repository from one of my machines to another, How can I \'git clone\' from another machine?.
I am now
An article I found that might be useful to others is Git in 5 minutes.
I had an Xcode project under Git version control that I wanted to push up to a Virtual Distributed Ethernet (VDE) I have in a DC. The VDE runs Centos 5.
None of the articles I read about Git talked about bare repositories. It all sounded so simple until I tried what I thought should be easy coming from an SVN background.
The suggestions here to make the remote repository bare worked. Even better for my requirements was to clone the Xcode project to projectname.git
, copy that to the remote server; then pushes magically worked. The next step will be getting Xcode to push without errors about commits, but for now I'm okay doing it from Terminal.
So:
cd /tmp (or another other directory on your system)
git clone --bare /xcode-project-directory projectname.git
scp -r projectname.git sshusername@remotehost.com:repos/
To push changes from your Xcode project after you've committed in Xcode:
cd /xcode-project-directory
git push sshusername@remotehost.com:repos/projectname.git
I'm certain there is a smoother more sophisticated way of doing the above, but at a minimum this works. Just so everything is clear, here are some clarifications:
/xcode-project-directory
is the directory your xcode project is stored in. It's probably /Users/Your_Name/Documents/Project_Name
.
projectname is literally the name of the project, but it can be anything you care to call it. Git doesn't care, you will.
To use scp you need to have a user account on the remote server that's allowed SSH access. Anyone running their own server will have this. If you're using shared hosting or the like, you might be out of luck.
remotehost.com
is the name of your remote host. You could as easily use its IP address. Just for further clarity I'm using Gitosis on the remote host with SSH keys, so I'm not prompted for passwords when I push. The article Hosting Git Repositories, the Easy (and Secure) Way tells you how to set all that up.