3 Answers
3

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 have git installed and don't even give you access to run gcc, 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:

> which git
/usr/local/bin/git

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:

git: 'index-pack' is not a git-command. See 'git --help'.

To find the directory containing the core git libraries on target_host, you can use this:

> git --exec-path
/usr/local/libexec/git-core

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 used scp, something like this:

If you forget this step, you may be surprised to see this error when you do a git push:

git-receive-pack: command not found

This is documented on the Git FAQ on git.or.cz:

Basically the problem is that 'git-receive-pack' is not in the default $PATH on the remote end.

...

Making sure you have the correct path set up in .bashrc (not only .bash_profile)

GIT_EXEC_PATH is documented on man git:

--exec-path
Path to wherever your core git programs are installed.
This can also be controlled by setting the GIT_EXEC_PATH
environment variable. If no path is given, git will print
the current setting and then exit.

In my case I just had to copy /lib/libcrypto.so.4 over to ~/lib on my target_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 a git push.

toolmantim.com explains the difference between a regular git repository and a bare repository:

A default git repository assumes that you’ll be using it as your working directory, so git stores the actual bare repository files in a .git directory alongside all the project files. Remote repositories don’t need copies of the files on the filesystem unlike working copies, all they need are the deltas and binary what-nots of the repository itself. This is what “bare” means to git. Just the repository itself.

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:

> cd ~/www/my_site
> git init

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:

> git push --all ssh://username@target_host:port/~/www/my_site/.git

You may see a warning like this if your repository on target_host isn't already up-to-date:

> warning: updating the current branch
> warning: Updating the currently checked out branch may cause confusion,
> warning: as the index and work tree do not reflect changes that are in HEAD.
> warning: As a result, you may see the changes you just pushed into it
> warning: reverted when you run 'git diff' over there, and you may want
> warning: to run 'git reset --hard' before starting to work to recover.
> warning:
> warning: You can set 'receive.denyCurrentBranch' configuration variable to
> warning: 'refuse' in the remote repository to forbid pushing into its
> warning: current branch.
> warning: To allow pushing into the current branch, you can set it to 'ignore';
> warning: but this is not recommended unless you arranged to update its work
> warning: tree to match what you pushed in some other way.
> warning:
> warning: To squelch this message, you can set it to 'warn'.
> warning:
> warning: Note that the default will change in a future version of git
> warning: to refuse updating the current branch unless you have the
> warning: configuration variable set to either 'ignore' or 'warn'.

(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 tell git to write out the contents of the index to the work tree itself, like so:

> ssh target_host 'cd ~/www/my_site/; git reset --hard'

(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:

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

It's more the git installation on the remote server that's troublesome though. Your answer (whilst useful) just covers the creation of the repository in a standard fashion.
–
Tom WrightJun 16 '09 at 23:14

1

Ahh, I see. I hadn't thought of that. You might be able to email godaddy's hosting support and see if they can install git for you, or at least the bare minimum deps for you to build it yourself. If not, you might be able to figure out what architecture it's running and compile your own on a similar one and upload that.
–
mattikusJun 16 '09 at 23:40