Setting up a git repo on my GoDaddy hosting plan

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.

  • Git Remote: Error: fatal: protocol error: bad line length character: Unab
  • Installing TextBelt on my own server
  • Managing library dependencies using git
  • Setup remote GIT repository via SSH? (No code access to the remote location)
  • Git - Do colours mean something in the editor that opens when I commit?
  • IntelliJ commit 50-character line length reminder
  • 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.

  • ci/cd independent microservices in monorepo with git bash
  • Can git submodule update be made to fetch tags in submodules?
  • Git shows no branches
  • How to copy a repository completely separate from the original, not a fork?
  • How do I clone a large Git repository on an unreliable connection?
  • Git Bash how to show info about repo files like in Git Shell
  • 9 Solutions collect form web for “Setting up a git repo on my GoDaddy hosting plan”

    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

    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 user@godaddyhost.com
    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…

    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.

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

    “scp -r fooDirectory user@host.com:/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

    Connect via ssh.

    Install git to ~/git.

    After that create/update these files:

    ~/.ssh/authorized_keys

    command="~/connect.sh" ssh-rsa AAAAB3NzaC...
    

    ~/connect.sh

    #!/bin/bash
    if [ -f "${HOME}/.env_profile" ]; then
            source ~/.env_profile
    fi;
    
    if [ "x${SSH_ORIGINAL_COMMAND}x" == "xx" ]; then
            $SHELL --login
    else
            eval "${SSH_ORIGINAL_COMMAND}"
    fi;
    

    ~/.env_profile

    export ENV_VARIABLE=value
    

    by git:

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

    I spent about a week to google this out, but it’s working like charm now… I don’t think there is another solution by godaddy accounts, the possibilities are too limited by them…

    I found another useful guide to install git on GoDaddy at http://www.612softwarefoundry.com/getting-git-on-godaddy/

    There is a YouTube tutorial explaining how to set up Git on a Godaddy Shared Hosting account. Here is the link:
    http://youtu.be/z60GLfsGGsY

    There is also a webpage with the commands that you will need to execute on the video. Here is the page address:
    http://www.drupalfever.com/linux-how-to/git/set-up-git-in-a-godaddy-shared-hosting-account

    If you have any question, leave me a note or suggestion.

    The instructions in this blog post worked for me, except that I had to visit EPEL and find the newest version of the git RPM: http://hire.chrisjlee.net/node/139

    Fetch the binaries

    cd ~
    mkdir git
    cd git
    # Download the rpm from EPEL ( http://fedoraproject.org/wiki/EPEL )
    # Find the latest version by checking http://dl.fedoraproject.org/pub/epel/5/i386/
    wget http://dl.fedoraproject.org/pub/epel/5/i386/git-1.8.2.1-1.el5.i386.rpm
    # Extract binaries from the rpm
    rpm2cpio git-1.7.4.1-1.el5.i386.rpm  | cpio -imdv
    rm git-1.7.4.1-1.el5.i386.rpm
    

    Configure

    echo "
    export GIT_BIN=${HOME}/git
    export PATH=${GIT_BIN}/usr/bin:${PATH}
    export GIT_EXEC_PATH=${GIT_BIN}/usr/bin
    export GIT_TEMPLATE_DIR=${GIT_BIN}/usr/share/git-core/templates
    export GIT_SSL_NO_VERIFY=true" >> ~/.bashrc
    

    Configure git

    mkdir ~/.git
    git config --local --add remote.origin.uploadpack ~/git/usr/bin/git-upload-pack
    git config --local --add remote.origin.receivepack ~/git/usr/bin/git-receive-pack
    

    I had to set up git on a VPS hosted at http://netgonian.com (GoDaddy reseller). What took 3 hours could have been done in about 15 minutes and super easy.

    Installing git should be as simple as running yum install git but unfortunately trying that gave me all sorts of could not find file errors. Below was the final solution.

    Here are the steps:

    1. ssh onto your virtual server
    2. change over to the root user using the command su -
    3. follow the instructions here to create a new centos-base.repo file
    4. in the same directory where you just created the above file (/etc/yum.repos.d) rename the file CentoOS-Base.repo to CentOS-Base.repox
    5. now you can run yum install git and it will work.

    The basic issue was that all the base urls for yum were pointing to some server on the secureserver.net that was missing all the needed files. What we are doing above is pointing the base urls to servers that have the needed files.

    Git Baby is a git and github fan, let's start git clone.