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 firstname.lastname@example.org 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-22.214.171.124.tar.gz is downloaded via curl. Execute the following: curl -O http://kernel.org/pub/software/scm/git/git-126.96.36.199.tar.gz tar xvfz git-188.8.131.52.tar.gz cd git-184.108.40.206 ./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 email@example.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://firstname.lastname@example.org/~/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 email@example.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!
Git Command Cheatsheet
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/
Leave a Reply