I have a project which is version-controlled using git.
What I want to be able to do is set up a repo on my (ssh-enabled) GoDaddy shared hosting package so that I can deploy with a push rather than dragging and dropping in FTP.
Any tips would be appreciated. Best would be an account from someone who's already done it, but I couldn't personally find any online.
I ran into the same problem with a site that I had hosted on a HostNine shared hosting package. They too give you
ssh
access, but they unfortunately don't havegit
installed and don't even give you access to rungcc
, making it rather difficult to download and install git for your user.The only way I could think of to work around these restrictions was to copy over the git binaries over from another computer that had them. Perhaps the same solution would work for you and your GoDaddy shared host. Here's what I did:
First figure out what architecture your server has. In my case it was 32-bit (i386). Here are a couple of ways to figure that out:
Next you need to find another computer running Linux with the same architecture and with git installed on it. They don't even have to be running the same distribution or version of Linux, as long as they're the same architecture and you can find the binaries and library files you need.
To find the location of the main git binary:
Some other important binaries (like
git-receive-pack
) also reside in the same directory, so I recommend just copying over all of/usr/local/bin/git*
to make sure you get everything you need.Other important files are that git depends on are under a 'libexec' directory somewhere on the source system. If you don't copy these over, you may get a surprising error message when you try to do a
git push
, like I did:To find the directory containing the core git libraries on target_host, you can use this:
I would recommend copying those files over first and then trying to run git to see if it complains about any missing shared libraries. If it doesn't, then you are (presumably) good to go. If it does, then keep reading. (No use copying over shared libraries if they already exist on the target host and are the correct version.)
You can copy the files with
scp
,rsync
,ftp
, or whatever you are comfortable with. I usedscp
, something like this:Then ssh to target_host. You will need to add some lines like these to your
~/.bashrc
:If you forget this step, you may be surprised to see this error when you do a
git push
:This is documented on the Git FAQ on git.or.cz:
GIT_EXEC_PATH
is documented onman git
:Source your new
~/.bashrc
. Now try runninggit
.This is what it gave me the first time:
I was able to figure out the location of the shared libraries to copy over by running this on the source machine:
In my case I just had to copy
/lib/libcrypto.so.4
over to~/lib
on mytarget_host
and everything was fine.Now you should have a working
git
on your shared hosting server and you should be able to push to it!Now you need to either create a new git repository and work tree on your server or copy your existing repository/work tree over.
By the way, I don't think a bare repository is what you want on the server in this case since you said you wanted to deploy the actual content files (as opposed to just the
config HEAD objects/ refs/
files that would be included in a bare repository) whenever you do agit push
.toolmantim.com explains the difference between a regular git repository and a bare repository:
I will assume for the moment that you have already created a directory on your
target_host
where you want to deploy your web site (or whatever you're deploying). Let's call that directory~/www/my_site
. You may have even ftp'd over all of your files to~/www/my_site already
. (Whether or not you have is not important.) I'll also assume for the moment that you didn't already copy the .git subdirectory over to~/www/my_site
(it should work just fine if you have though).Since there's not already a git repository initialized on target_host, your first step would be to create one:
Then from whichever host has the repository with the latest changes you want to deploy (your development box, I would guess), you just have to do something like this to deploy:
You may see a warning like this if your repository on
target_host
isn't already up-to-date:(In normal
git
usage you never see that message, I think, because you're normally pushing to bare repositories. But since our remote repository in this case is a normal repo with both a work tree and an index,git
is understandably concerned that it might mess something up.)I think it's safe for us to set it to 'ignore' on your server, though, because you're not likely to be making any commits directly to the repository there. (All commits should probably originate in your development repository and then be pushed to the server.)
So go ahead and set this so you won't see the warning every time you push:
The
push
itself only updates the index, however, NOT the files in the work tree itself. Updating those files is only kind of the entire point of what we're trying to do, though, so our job isn't done until we tellgit
to write out the contents of the index to the work tree itself, like so:(Note: Any changes you may have had in your work tree on the server will be overwritten by what's in the repository.)
I also followed mattikus's suggestion and created a remote for my server:
So now all I have to do to deploy is:
I even went so far as to throw these commands in a script I named
script/deploy
so any time I want to deploy I just have a single command to run.Please let me know if you find any mistakes in these instructions or if you know of a better solution.
I'm both a SF and godaddy n00b, so bear with me, but anyway, I'm very happy to see this discussed here.
Just my $0.02, I attempted building git (dynamically) on my linux box, hosing it over to my godaddy account, and even if attempting merely to push to the otherwise passive godaddy machine, it fails due to missing openssl. Maybe if I attempt to build git statically with openssl, but it feels like a bad idea too.
Off topic, but is this the sort of lack of support I should expect from godaddy, should I regret not choosing dreamhosts instead?
Best regards CJ
PS. Not an answer, but a suggestion that once git-receive is working on godaddy (is it?), then a repository with a detached worktree is a great way to deploy for web: http://toroid.org/ams/git-website-howto
The easiest way to do this is by running something like this on your remote server:
Then on your devel checkout:
There's no server or anything else required, and you should be able to fetch/pull from that machine as well as long as you have ssh access.
If you have your .ssh/config set up as well, it should take advantage of that and use any private keys you may have set up.
If you plan on pushing out updates a lot, you can add a remote repo to your devel checkout:
Then from then on you can:
For more info, check out the online docs on
git push
or rungit push --help
to launch the man page on your local.