Installing Git on Godaddy

& so I was sitting and pondering upon which revision control system I should deploy for an ongoing project, seeing that I’ll be needing someone to work on my application UI design in the near future, when my good friend Sola Ajayi, an avid & well matured developer swayed me towards Git. After much persuasion on the benefits, I decided to give it a go, and I’m certainly glad I did.

So what is Git?

Git is a free & open source, distributed version control system designed to handle everything from small to very large projects with speed and efficiency.

Git is used for version control of files, much like tools such as Mercurial, Bazaar, Subversion, CVS, Perforce, and Team Foundation Server.


I have a shared dedicated hosting plan with, while my actual development files are local on my system. I needed a scenario where once i’m done with a web-dev session, I would only upload files I modified and keep track of those changes rather than the whole project.

What you need:

  1. A GoDaddy hosting account: Obviously this tutorial assumes you have a GoDaddy hosting account or you intend to use one. The steps described below in installing Git are unique to GoDaddy because they use CentOS 5 linux operating system [at least my hosting account uses that]. so it will only work on other hosting servers if they are similar to GoDaddy’s configuration.
  2. Some Git knowledge: If you don’t have any experience or knowledge you can find some in their Community Book.
  3. Git installed: You need git installed on your local machine: Download from Git Website.
  4. SSH client: Hopefully if you installed properly from step 3 above you should have this installed.
  5. Bash shell on local machine: Same as step 4.

Setup Git on GaDaddy

As you know, Git is not installed on GoDaddy by default, and since the assumption is that you don’t have root access you’ll have to copy pre-complied binaries for CentOS 5 provided below to your hosting account on GoDaddy, so lets get cracking.

  • Step One: Enable SSH for your GoDaddy hosting account. GoDaddy documentation can be found on their help pages. Note that it takes some time for SSH access to come up, once its up you may proceed.
  • Step Two: Make sure you have at least one FTP account created.
  • Step Three: Setup password-less authentication using Public/Private keys on your ssh account. Here’s a tutorial if you need help:  Password-less SSH
  • Step Four: Use Git Bash Shell [Should be in you programs line up] Connect to your ssh account using the following:


    Use your ftp user login as “username” and the hosting account domain as “domain”. If it’s your first time connecting via ssh, it should ask you to add the domain to the list of know hosts, type yes and continue.

  • Step Five: Download the git binaries to your GoDaddy account by running the following command:


    These binaries were compiled from the GIT (version on a linix machine running CentOS 5.2, which is the same operating system that my GoDaddy hostng account is running. Usually, linux binaries are relatively portable so these might also work on other servers running a different operating system. In the event they do not work, you can compile them yourself using a virtual machine with the same OS specifications as your web host uses.

  • Unpack your freshly downloaded binaries using the following command:

    tar -xvjf git-

  • Now use your favourite text editor and add the following lines to the bottom of this file: ~/.bashrc
    export GIT_BIN=${HOME}/git
    export PATH=${GIT_BIN}/bin:${PATH}
    export GIT_EXEC_PATH=${GIT_BIN}/libexec/git-core

    Note: if the file ~/.bashrc does not exist, create it and copy those lines to it. After adding those lines, you’ll have to modify ~/.ssh/authorized_keys file, Here’s a sample of my ~/.ssh/authorized_keys file:

    ssh-rsa AAAAB3NzaC1yc2
    7z3/hfNJLjgEO6yKIkY8Y29gj86KjfZVU2tQ== Chuka@CHUKA-PC

    Next add the following code to the beginning of the file:

    command="if [[ \"x${SSH_ORIGINAL_COMMAND}x\" == \"xx\" ]]; then /bin/bash; else source ~/.bashrc; eval \"${SSH_ORIGINAL_COMMAND}\"; fi; "

    This tells your ssh session where it can find your git binaries every time you login remotely via ssh and try to run a command.

  • The next step is to initialize a bare repository on your GoDaddy servers to which you will be publishing from your local server. Create a folder in your hosting account home folder named “repo”, change directories to it and run the following commands:

    mkdir ~/repo
    git init –bare –template ~/git/share/git-core/templates ~/repo/app_name.git
    cd ~/repo/app_name.git
    git update-server-info

    After creating your online repository, you may logout from your GoDaddy server.

Setup & Publish your local repository

Here, you’ll be initializing and setting up a new local Git repository (You can use your development IDE, NetBeans in my case to do this if it has a Git plugin) and tell your local repository where to publish your file to on GoDaddy’s server. For the purposes of this tutorial I will be using ”app_name” as project name.

  1. Change directories to your local application folder and run the following commands, don’t forget to substitute your local application path.

    cd /c/xammp/htdocs/app_name/
    git init

  2. Next step is to add all files in your app to your local repository. But before that, Git records your name and email address with every commit you make, so you’ll need to tell Git what these are. Run following commands:

    git config –global ‘Your Name’
    git config –global ‘’

  3. Next, we add all files to the repository and then we commit everything

    git add .
    git commit -m “Initial Commit” .

  4. Next we’ll tell our local server where to find our GoDaddy online repository which we setup in the previous section of this tutorial:

    git remote set-url origin ssh://

    Note that we used a “/” after the domain syntax instead of “:” as we would normally would for ssh.

  5. We are now ready to do our initial push to GoDaddy servers online:

    git push origin master

    If all goes well, you should be able to push your local repository to GoDaddy successfully.

  6. Now that we are able to push files online, there’s just one last bit we need to tidy up; ssh into your GoDaddy account and run the following command:

    git clone –template ~/git/share/git-core/templates ~/repo/app_name.git ~/html/app_name
    cd ~/html/app_name
    git pull

    This makes a clone of your repository and deploys files to your web-server [could also be your live-site]. The next command “git pull”, retrieves all files which has been pushed to your online repository from your local machine and makes sure its up to date.

    If you want to update your live-site automatically any time you do a “git push”, you’ll have to make use of the “post-receive” hook file. Use your favourite text editor and create the file ~/repo/app_name.git/hooks/post-receive and copy the following lines to it:

    export GIT_DIR="$WORKDIR/.git"
    echo "Starting Pull"
    cd "/FULL/PATH/TO/html/app_name"
    git pull
    echo "Pull finished Successfully"

    Note: you can get your full path by running “pwd”. Now hopefully if you followed these steps correctly, you should now be able to do a git push and update your GoDaddy repository and effect changes to your live-site at once.

I hope you found this tutorial quite helpful.
PS: I picked Sola’s brain a lot while writing this :)



Fill in your details below or click an icon to log in: 徽标

You are commenting using your account. Log Out /  更改 )

Google+ photo

You are commenting using your Google+ account. Log Out /  更改 )

Twitter picture

You are commenting using your Twitter account. Log Out /  更改 )

Facebook photo

You are commenting using your Facebook account. Log Out /  更改 )


Connecting to %s