Installing and Setting up a GIT repository on BlueHost

admin 03/04/2011

A brief explanation about how to install and setup a git repository will be described here.
In order to remotely access your git repositories you must setup a SSH account with bluehost, so log in to your Bluehost account and look for the option SSH. You must send an copy of your ID and wait for them to setup an account for you
(I used my webcam to take a picture of my ID and that was more than enough).

Installing git in your Bluehost server.

1) Create a place to install the git binary files.
In my case, I’ve created a local folder “.local” inside my $HOME folder (~/.local).

#cd ~
#mkdir .local

2) Edit your .bashrc file and add the following line. Logout and login again to apply changes.

export PATH=$HOME/.local/bin:$HOME/.local/usr/bin:$PATH 

3) Create a folder “~/.local/src”, download the latest version of git (in my case and compile it

#cd ~/.local
#mkdir -v src
#cd src
#tar -xzf git-
#cd git-
#./configure --prefix=$HOME/.local LDFLAGS="-L/lib64"
#make install

How to setup and access a git repository in the server locally

1) Create a “~/git/repository” folder that will contain your files

#cd ~
#mkdir git
#cd git
#mkdir repository

2) Create a bare repository using git init

A bare repository works like a SVN server repository. This means that a bare repository only keeps track of
changes from someplace else and you actually don’t work inside it.

#cd ~/git/repository
#git init --bare --share 

3) Create a working copy folder by cloning your empty repository, add files to the cloned folder, commit and push the changes back to your bare repository.
In order to use the bare repository, a master banch needs to be created. This is accomplished by using “git add .”.
This command tells git to add all files and folders to the repository (in this case I’m creating a test file,
here you could copy your files to this folder before executing this command).

#cd ~/git
#git clone ~/git/repository myfolder
#cd myfolder
#echo This is a test file > text.txt
#git add .

Note that, distinct from SVN, you must commit then push the changes back to the bare repository. In git, the command commit
saves the changes to your cloned local repository; the command push will actually send the changes to your main bare repository.

#git commit
#git push ~/git/repository/ master

At this point you have a fully functional bare repository.
To test it, lets delete “~/git/myfolder” and create another clone.

#cd ~/git/
#rm -rf myfolder
#git clone ~/git/repository/ myfolder2
#cd myfolder2
#cat test.txt

You should be able to see the contents of test.txt

Accessing your bare repository remotely

Please note that I’m not covering how to install git in your local machine, but that should not be an issue since
the process above cover any linux install. For windows users, there are plenty of how-tos in the web. The binaries
can also be found in

The steps below describe how to access a remote git repository through SSH installed in BlueHost

1) In your local machine, create a folder and use “git init” to start a fresh repository.
This folder will contain a working copy of your repository.

mkdir mylocalfolder
cd mylocalfolder
git init 

2) Create an alias “myrepository” to identify the remote repository to git. Note that
must be changed by your actual domain hosted on Bluehost. Please also check the path to your home folder
(you can use “echo $HOME” in the server to check it)

git remote add myrepository

3) Map the git commands “git-upload-pack” and “git-receive-pack”.

This is the trick that makes git work remotely with Bluehost. Remember checking and replacing “/home/myuser” folder
for your actual home folder (you can use “echo $HOME” in the server to check it)

git config add remote.myrepository.uploadpack /home/myuser/.local/bin/git-upload-pack
git config add remote.myrepository.receivepack /home/myuser/.local/bin/git-receive-pack

Alternatively, you also can change thoose properties by editing the file “mylocalfolder/.git/config”
The file should contain a session like this

[remote "myrepository"]
	url =
	fetch = +refs/heads/*:refs/remotes/repository/*
	receivepack = /home/myuser/.local/bin/git-receive-pack
	uploadpack = /home/myuser/.local/bin/git-upload-pack

4) Finally, pull your files from your bare repository (branch master in this case) to your work folder

git pull myrepository master

Your working copy is ready to go. Just remember, after any change use

git add .  
git commit 
git push myrepository master

A good GIT by example guide can be found at

Please let me know of any typos.

I hope you all find this tutorial useful!



About the Author


  • May 9, 2011 at 8:11 am

    Great tutorial. Works a charm.

    Many thanks 🙂

  • Maria
    May 25, 2011 at 8:08 pm

    wow, thanks a bunch. I was messing around with my .bashrc file all morning before finding out that bluehost no longer allows remote paths to be accessed via non-interactive logins. If only I had discovered this 4 hours sooner!

  • Ben
    July 31, 2012 at 9:44 pm

    Thanks …this method is nicely written, but I was unsuccessful with it at the point of trying to push, e.g. #git push ~/git/repository/ master

    It worked if I tried a committing and pushing a small number of files for test purposes, but it failed when I added a whole drupal web site into the working directory, with this message:

    git push ~/repos/myrepo/ master
    Counting objects: 1576, done.
    Delta compression using up to 32 threads.
    fatal: unable to create thread: Resource temporarily unavailable

    I’ve not looked into whatever thread limiters bluehost may have.

  • Cristobal
    September 16, 2012 at 4:41 am

    Thanks a lot, great tutorial
    worked for me with different receive and upload pack paths:
    receivepack = /usr/bin/git-receive-pack
    uploadpack = /usr/bin/git-upload-pack

  • October 3, 2012 at 4:13 pm

    thanks bro

  • December 24, 2012 at 2:48 pm

    urls are changed to:
    wget –no-check-certificate

  • July 17, 2013 at 10:58 am

    Is ther anyway with bluehost..?


Leave a Reply

= 4 + 4