Installing a Private Git Repository on your Shared Hosting Account, BlueHost

The reason I added this blog entry is because I tried to set up a private Git repository on BlueHost (shared hosting account) and didn’t find all of the information I needed in one place. I called BlueHost and they told me they allow it but won’t support it. Initially, I wasn’t sure if it was possible to do it. However, one person at BlueHost indicated to me that it’s possible to do set this up on BlueHost so I continued my efforts and became successful in setting this up. I’m a RoR developer and also starting iPhone development with a friend. We were investigating different SCM to use and how we can set up a remote Git repository we both could connect to, but also didn’t want to spend any more money than we already are. BlueHost allows you to host unlimited domains, allows you to host RoR sites, provides an ssh account so it provides everything we need, at least while still very small.

Install Git on your BlueHost shared hosting account (build from source code):

You should only do the following on smaller projects with up to a few people on the project or else BlueHost may kick you off! Also, call BlueHost first to see if they allow you to do this before you sign up with them, since they may have changed their service over time. As of 7/15/2009, it works. Also, not sure how fast Git is on BlueHost yet. Use it for very small projects. There’s a link to BlueHost below. Also, I’m not responsible for any steps. Be sure you understand what each step is doing before proceeding!

If you’d like to support and encourage me in writing more articles, please sign up with BlueHost through this link BlueHost, so I can get something out of it. I would greatly appreciate this. Thanks! – Navid

You must first have access to a ssh account on BlueHost. Make a request for that with them. You have to send them a copy of your driver’s license to activate it. I also assume you know Git. BlueHost doesn’t officially support Git but they allow you to use it if you can do this on your own. They also currently have a 50k file transfer limit of some sort currently but you should double-check this with them, as this restriction can change over time.

ssh username@yourdomain.com and create a temporary src directory (mkdir ~/src)

cd ~/src

Go to <a href="http://git-scm.com/download" target="_blank">http://git-scm.com/download</a> and download the latest tarball of git. In this example git-1.6.3.3.tar.gz is downloaded via curl. Execute the following:

curl -O http://kernel.org/pub/software/scm/git/git-1.6.3.3.tar.gz
tar xvfz git-1.6.3.3.tar.gz
cd git-1.6.3.3
./configure --prefix=$HOME
make SHELL="/bin/bash" install

To test if Git was successfully installed type: git --version
To see where Git was installed type: which git, it should be created under ~/bin/git
You can now delete your temporary ~/src directory where you built Git from source code.

Setting up your Remote Private Git Server

  • ssh username@yourdomain.com
  • Edit your ~/.bashrc file and add the export line after the line with # User specific aliases and functions:
# User specific aliases and functions
export PATH=$PATH:$HOME/bin

mkdir -p ~/git/yourproject.git
cd ~/git/yourproject.git
git --bare init

Local Set Up (these steps assume you already have git installed on your local machine)

mkdir yourproject
cd yourproject
git init
git remote add origin ssh://username@yourdomain.com/~/git/yourproject.git
touch .gitignore
git add .
git commit -m "Initial Commit"
git push origin master

Append the following to your .git/config file within the yourproject directory you just created

This will allow you to do just a ‘git push’ and ‘git pull’, for example, without needing to specify the name of your remote repository as an argument.

[branch "master"]
        remote = origin
        merge = refs/heads/master

To create a clone of the remote repository and its files

cd [to_a_directory_above_where_you_want_the_project_files_to_go]
git clone username@yourdomain.com/~/git/yourproject.git

If you want to be able to use Git without having to type in your BlueHost password or share your Git repository with a friend without them having to type a password, append the ~/.ssh/id_rsa.pub from the local machine, from each box you want to provide access, to the end of the ~/.ssh/authorized_keys on the remote (BlueHost) account. Only add trusted public keys (from people you trust) to the authorized_keys of the remote server where the Git repository is!

I wrote a Git Command Cheatsheet which will show you common git commands which you can use as a reference. I highly recommend bookmarking and sharing this page.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Thanks to http://joemaller.com/2008/08/13/how-to-install-git-on-a-shared-host/, http://railstips.org/2008/11/24/gitn-your-shared-host-on, http://www.bluestatic.org/blog/2007/08/01/git-public-push-ing/

VN:F [1.9.22_1171]
Rating: 4.9/5 (12 votes cast)
VN:F [1.9.22_1171]
Rating: +4 (from 4 votes)
Installing a Private Git Repository on your Shared Hosting Account, BlueHost, 4.9 out of 5 based on 12 ratings
Facebook Twitter Email

20 Comments to “Installing a Private Git Repository on your Shared Hosting Account, BlueHost”

  1. DrupalFever 31 August 2013 at 12:52 pm #

    I made a YouTube tutorial for Godaddy but it should work for BlueHost as well.

    Following is the address for that tutorial:
    http://youtu.be/z60GLfsGGsY

    Good luck!

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  2. navid 13 June 2012 at 11:02 pm #

    You should be able to just create it in your BlueHost account.

    VN:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VN:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  3. Bluehost Customer 10 June 2012 at 6:34 am #

    Hi, One thing I don’t understand is where to find ~/.ssh/authorized_keys on the remote machine (Bluehost). Any idea?

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  4. Robert 3 February 2012 at 11:57 am #

    Thanks! Great article.
    I’d like to make one correction: for the git clone command, in order to git it to work for me, I prepended ssh:// to the url, such as:

    git clone ssh://username@domain.com/~/git_project

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  5. cebimedia 16 February 2011 at 10:12 am #

    Thank you so much Navid for the awesome tutorial

    p.s anyone has problems with git-pack issue should check out http://bit.ly/f533U0 :)

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  6. Stephen 10 December 2010 at 12:15 am #

    Great walk through. Worked perfectly with the exception of the git-**-pack issues. Adding these locations to the local git config did the trick. Thank you Carl for posting that link!

    Again.. thanks for this.

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  7. […] you. If you ask them to install it, they tell you they don’t support it). Then I found this post by Navid Kamali on how to install git from source on your account. Since I don’t need a full […]

  8. Carl Rennie 30 August 2010 at 1:14 am #

    It turns out that bluehost has disabled running .bashrc for non-interactive logins, which means that the path done in the .bashrc in this post won’t actually do anything. You need to specify where your git-receive-pack and git-unload-pack files are.

    See http://www.n8williams.com/devblog/general_dev/bash-git-receive-pack-command-not-found for more information, especially the second part.

    VA:F [1.9.22_1171]
    Rating: 5.0/5 (2 votes cast)
    VA:F [1.9.22_1171]
    Rating: +1 (from 1 vote)
  9. Daniel 17 August 2010 at 7:31 pm #

    For everyone having trouble doing a git push, try:

    git push –exec=”\$HOME/bin/git-receive-pack”

    You need to escape the $ in HOME so that your local bash does not turn it into your local home directory.

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  10. Emer 7 July 2010 at 9:11 pm #

    I’m with the same problem of Chris (already did the git add . and git commit…). The error message is

    bash: git-receive-pack: command not found
    fatal: The remote end hung up unexpectedly

    I checked on the server and the path on bashrc is OK. the command git-receive-pack can be executed from anywhere there.

    anyway, thanks for sharing this!

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  11. navid 11 May 2010 at 10:41 am #

    Chris,

    You already did the following before doing a “git push origin master”, right?:

    git add .
    git commit -m “Initial Commit”

    VN:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VN:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  12. navid 11 May 2010 at 10:38 am #

    Dave,

    Use FTP (file transfer protocol), SFTP (secure file transfer protocol) or SCP (secure copy) to copy local files onto your server.

    VN:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VN:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  13. Chris Barrett 11 May 2010 at 3:05 am #

    Thanks for posting all this, I found it extremely useful and well-presented.

    I’ve just had one problem: while following the directions given, anytime I try to “git push origin master”, I receive simply “fatal: The remote end hung up unexpectedly”. I’ve been looking around for a few hours now, and can’t seem to figure out what the problem is.

    Thanks again for what you’ve done here. It’s exactly what I was looking for. Any further help is also very much appreciated.

    VA:F [1.9.22_1171]
    Rating: 1.0/5 (1 vote cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  14. Dave 17 March 2010 at 6:43 am #

    Thanks for this post, it was the best I found and helped a ton.

    Perhaps I’m missing something… but what is the standard way one might deploy/ftp/apply the changes made in their local project onto live website? As I understand, pushing to a git repository doesn’t necessarily achieve this (or does it?).

    Specifically I have in mind just basic files, not necessarily RubyOnRails or anything (which I am guessing may be a bit more complicated). Thanks!

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  15. Mike Fischer 9 January 2010 at 7:47 pm #

    Did this today, thanks!

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: +1 (from 1 vote)
  16. Chris Apolzon 1 January 2010 at 5:10 pm #

    Thanks! Great post, I remember having a hard time finding info on doing this on dreamhost…fully setup in under 15 minutes is astounding.

    VA:F [1.9.22_1171]
    Rating: 5.0/5 (1 vote cast)
    VA:F [1.9.22_1171]
    Rating: +1 (from 1 vote)
  17. Bluehost User 2 8 December 2009 at 12:47 pm #

    Thank you so much! 5/5… tried the same on hostgator didnt work. Glad I chose bluehost. But next time I’ll chose linode ;)

    VA:F [1.9.22_1171]
    Rating: 3.0/5 (1 vote cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 2 votes)
  18. […] Article… Setting up Private Git Repository on Shared Hosting Server, BlueHost VN:F [1.6.3_896]please wait…Rating: 0.0/5 (0 votes cast)VN:F [1.6.3_896]Rating: 0 (from 0 votes) […]

  19. […] up a Private Git Repository on the Server. See Installing a Private Git Repository on your Shared Hosting Account, BlueHost (BlueHost doesn’t support this but it’s possible, as I’ve done […]

  20. BlueHost User 23 August 2009 at 8:21 pm #

    Thank you so much! I had been wrestling with myself for awhile!

    VA:F [1.9.22_1171]
    Rating: 4.5/5 (2 votes cast)
    VA:F [1.9.22_1171]
    Rating: +1 (from 1 vote)

Leave a Reply