Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting up a git repo on my GoDaddy hosting plan

Tags:

git

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.

like image 576
Tom Wright Avatar asked Jun 16 '09 20:06

Tom Wright


4 Answers

With a little work, I was able to get Git running on my GoDaddy account. There's a longer posting detailing the process on my blog, but the short answer is:

  1. install git in your account (perhaps using the tarball referenced in my blog post)
  2. create a git repository (bare or not) in your account
  3. check out your repository, using -u to indicate the path to git-upload-pack

    % git clone -u libexec/git-core/git-upload-pack mysite:myrepo.git

  4. tweak your local repository config to point to the correct paths to git-upload-pack and git-receive-pack:

    % git config remote.origin.receivepack libexec/git-core/git-receive-pack
    % git config remote.origin.uploadpack libexec/git-core/git-upload-pack


Since the blog is no longer accessible, here is the full post pulled from archive.org:

Using Git on GoDaddy

This blog is hosted on a cheap GoDaddy account. When shell access over SSH was recently made available, I thought it would be fun to install local git repositories. It wasn’t trivial, but I did finally get it working. Here’s how I did it:

Step 0. Configure SSH

You want to create a public key so you can SSH in to your GoDaddy account painlessly. Create a key pair if you don’t already have one, and add it to ~/.ssh/authorized_keys. I’ll assume an entry in ~/.ssh/config something like this:

Host mysite
HostName mygodaddysite.com
User mylogin

Step 1. Install Git

After poking around on my GoDaddy host, I discovered it was running CentOS 5.2. Binaries running on my laptop weren’t compatible, so I used VirtualBox to set up a local Centos 5.2 install and build Git. I’m sharing a tarball containing the pre-built CentOS 5.2 Git binaries. You should be able to download and install with the commands:

wget http://johntrammell.com/centos5.2-git.tar.gz
tar xzf centos5.2-git.tar.gz

Enjoy this part–I’ve saved you a couple hours’ work here.

Step 2. Set up your environment.

Add the following to your .bash_profile:

export EDITOR=vim
export PATH=$PATH:$HOME/bin:$HOME/libexec/git-core
export LD_LIBRARY_PATH=$HOME/lib
export GIT_EXEC_PATH=~/libexec/git-core
export GIT_TEMPLATE_DIR=~/share/git-core/templates

This will set your environment up correctly on an interactive shell. Unfortunately I can’t seem to get the PATH to set correctly for non-interactive SSH commands. For example, when I run this command from my laptop:

ssh mysite env

I see the default PATH. This is also the case when I set the path in .bashrc. I haven’t tracked down exactly what SSH does on non-interactive access, but this may be related to the PermitUserEnvironment setting in sshd. Luckily we can work around this.

Step 3. Creating a repository

Log in to your GoDaddy account, and create a simple “bare” Git repository:

% mkdir myrepo
% cd myrepo
% touch README
% git init
% git add README
% git commit -m 'empty git repository'
% cd ..
% git clone --bare myrepo myrepo.git

You now have a bare repository in ~/myrepo.git/ in the root of your GoDaddy account.

Step 4. Checking out your repository

The only tricky part to this is that you have to tell git where to find git-upload-pack. This works around the PATH problem mentioned above. On your local machine, do this:

git clone -u libexec/git-core/git-upload-pack mysite:myrepo.git

You should now have a copy of the original minimal repository checked out.

Step 5. More git configuration tweaks

Sadly we are not done:

% cd myrepo
% echo "foo" > README
% git commit -am 'updated'
[master 044c086] updated
 1 files changed, 1 insertions(+), 0 deletions(-)
% git push
bash: git-receive-pack: command not found
fatal: The remote end hung up unexpectedly

Our PATH problems are interfering with the push operation now. As a workaround, we can either specify –receive-pack on the command line, or set it in the local configuration (the same applies for fetch operations and –upload-pack):

% git config remote.origin.receivepack libexec/git-core/git-receive-pack
% git config remote.origin.uploadpack libexec/git-core/git-upload-pack

Congratulations, you should be up and running now!

Resources

  • http://johntrammell.com/centos5.2-git.tar.gz
  • https://serverfault.com/questions/26836/setting-up-a-git-repo-on-my-godaddy-hosting-plan
  • Setting up a git repo on my GoDaddy hosting plan
  • git-upload-pack: command not found, how to fix this correctly
  • http://www.bluehostforum.com/showthread.php?20304-Bluehost-Solution-to-the-Git-PATH-issue-when-using-a-non-interactive-shell
  • http://www.google.com/search?q=ssh+setup
  • http://www.kernel.org/pub/software/scm/git/docs/git-upload-pack.html
  • http://www.kernel.org/pub/software/scm/git/docs/git-receive-pack.html
like image 115
John Trammell Avatar answered Sep 22 '22 12:09

John Trammell


First, you will need to have git installed on GoDaddy. I'm not sure if this is possible. Git supports local user installs, but you need to have certain development tools handy to do it. Download git, and see if you can ./configure && make && make install -- if so, it will put it in your ~/bin directory.

We use git extensively for controlling production. But rather than deploying on push, may I suggest that you ssh to the box and do a git pull ?

More specifically, create a "Release" branch, and then when you are ready to deploy, simply merge your changes into the Release branch, ssh to the server, and git pull.

For example

ssh [email protected]
cd /path/to/project

#ok, assuming you are on the Release branch
git fetch
git merge branch-with-new-changes-on-it

# update the remote Release branch with the merge
git push origin HEAD

This simple workflow allows developers to see exactly what is on the production server at all times, and to merge other changes in with theirs before asking for a deployment. In fact, we require that all production changes be fully merged before requesting a deployment of your branch.

--

If you do manage to get git installed on GoDaddy, and you REALLY want to auto-deploy when you push to it, then take a look at the post-update hook.

http://git-scm.com/docs/githooks

--

If you cannot get git installed on GoDaddy, then see if they support rsync. Then you can have a simple bash script somewhere that will

  1. pull your changes
  2. rsync them to godaddy

--

There are many ways to do it. Perhaps this will help with direction a bit...

like image 33
gahooa Avatar answered Sep 20 '22 12:09

gahooa


I was successful following the directions here:

http://www.krizka.net/2010/12/30/setting-up-a-public-git-repository-with-godaddy-shared-hosting/

The keys (for me) were

  • Getting the precompiled binary for CentOS (from a link in post above)
  • Setting the "uploadpack" and "receivepack". This is step 1 in the section "Letting local git know about remote git" near the end of the post.
like image 27
tbc Avatar answered Sep 21 '22 12:09

tbc


I maitain git locally and use scp to push live... it's not elegant, but godaddy has scp installed my default.

"scp -r fooDirectory [email protected]:/path/to/document/root/"

that will move a local directory "fooDirectory" to "/path/to/document/root/fooDirectory" on the remote host.

when you are logged into go daddy use "pwd

like image 43
Lance Caraccioli Avatar answered Sep 18 '22 12:09

Lance Caraccioli