How to connect git repo to Godaddy hosting server

In this post, you will learn how to connect git repo to Godaddy hosting server. This is for a Linux shared hosting account with GoDaddy.

Install Git on your GoDaddy shared hosting server

Server does not come with git pre-installed. Therefore you need to SSH to your server and download/unpack Git. You can set-up your SSH access by following these instructions provided by GoDaddy.

1. Open Terminal and login to your hosting account:

2. Download the GIT binaries:

These binaries have been compiled from Git (version 1.7.3.4) on a Linux machine running CentOS 5.2, which is the same operating system that my GoDaddy server runs. Linux binaries are usually portable so these might also work on other servers running a different operating system. If they don’t work, you can compile them yourself using a virtual machine with the same operating system specifications as your hosting account.

3: Unpack the downloaded Git binaries:

Set up the Git repository So now Git is installed on your server, you can go ahead and create a Git repository. Let’s say we’re going to create this repository in the home directory:

A. Go to the home directory:
$ cd ~/public_html

B. Initialise your Git repository:
$ git init

C. Change the permissions to protect your git repository, as it will be visible on the web:
$ chmod 770 -R .git

D. Accept pushes from your local repository:
$ git config receive.denyCurrentBranch ignore

E. Go to the ‘hooks’ directory then edit the ‘post-receive’ file:

Add the following into top of file:
GIT_WORK_TREE=../ git checkout -f

Save these changes to the file and exit it.

F. Change the permissions for this file:
$ chmod +x post-receive

That’s your Git repository set-up and all the necessary housekeeping done.

Clone your Git repository to your machine

Git is now installed on your server and you’ve set-up the repository for your site. You now need to clone this repository to your machine. To keep this tutorial simple, we’re going to clone this repository onto the desktop.

1. Open a new tab in your command line editor, then go to the desktop directory:
$ cd ~/Desktop

2. Clone your live respository:
$ git clone [email protected]:public_html

3. Add your site files to your local folder, then commit/push them up to the server:
$ git add -A

$ git commit "Your commit message here"

$ git push origin master

Your local files are now up on your server and you’re good to go. Any amendments to your site from now on will be tracked and can be pushed up to your GoDaddy shared hosting server using Git.

If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.

Recommended Posts:


Prem Tiwari

An engineer by profession and a passionate blogger by heart. Founder of FreeWebMentor.com (A Programming blog for beginners), Tech Speaker at various forums. A part from this he is an open source enthusiast, WordPress Lover, Blogger, SEO, and Growth Strategic.