“is bemused/awed by how fast svn became a legacy technology in ruby community/developers” Dr. Nic recently said on Twitter. It is true. Greatly aided by Geoffrey Grosenbach’s screencast on git, I myself is starting to feel comfortable enough with git to start abandoning subversion altogether.
Github is great, but there is really no reason to pay for private git repositories unless you need the added functionality. I have a Dreamhost account that I am happy with, so why not use that for my private git repos? It is easy to do through SSH, now that git is installed on all Dreamhost servers, but it is not that easy, so I thought I’d better document it here for my own future reference.
(This stuff is tested on Mac OSX, and should work fine for *nix users. Windows users will have to do some workarounds, but can use this as a reference point.)
Create and add your public key (optional)
If you are used to use SSH access with Dreamhost, you probably already have this step setup, but if you don’t, this will help you avoid having to type your password everyone you connect through SSH, which will be every time you pull and push to and from the git repo on Dreamhost.
If haven’t done any SSH at all, you will probably need to generate a public/private set of RSA keys:
ssh-keygen -t rsa
Then you’ll need to to add your public key to your server (thanks to Dave the Wave for this trick):
cat .ssh/id_rsa.pub | ssh user@domain.tld 'cat >> .ssh/authorized_keys'
And with that, you can SSH to the server without typing your password, which is almost a must when doing git over SSH.
Create the dreamgit shell script
Toolman Tim explains very well how to setup a remote git repository over SSH, but it is easy to mess things up, and I’m planning on doing all my stuff in git from now on – so an automated script to suit my needs is essential.
I am not an expert in either git or shell scripting, so this script can probably be optimized quite a bit – in fact I am more than willing to update it if I get any comments from the real experts out there. But this script works for me:
DREAMGIT_DOMAIN=user@domain.tld
ssh $DREAMGIT_DOMAIN 'mkdir -p ~/git/'$1'.git && cd ~/git/'$1'.git && git --bare init'
mkdir $1
cd $1
git init
git remote add origin ssh://$DREAMGIT_DOMAIN/~/git/$1.git
touch .gitignore
git add .
git commit -m 'Created new repo'
git push origin master
echo "
[branch \"master\"]
remote = origin
merge = refs/heads/master" >>.git/config
echo "Your new git repo '$1' is ready and initialized at $DREAMGIT_DOMAIN/~/git/$1.git"
Put the above code into a file you place in a directory in your PATH. Remember to change user@domain.tld to your real Dreamhost SSH user and domain. I’ve selected to name the command dreamgit and put it in /usr/local/bin like this:
sudo mate /usr/local/bin/dreamgit
Paste the code in and save the file. Make your new command executable:
sudo chmod a+x /usr/local/bin/dreamgit
You now have a new command – dreamgit – that you can invoke in any directory on your local machine. You call it with a single argument – the name of your project – like this:
dreamgit test05
Initialized empty Git repository in /home/.char/cfp/git/test05.git/
Initialized empty Git repository in .git/
Created initial commit f4fbb71: Created new repo
0 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 .gitignore
Counting objects: 3, done.
Writing objects: 100% (3/3), 220 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To ssh://cfp@casperfabricius.com/~/git/test05.git
* [new branch] master -> master
Your new git repo 'test05' is ready and initialized at cfp@casperfabricius.com/~/git/test05.git
As it says – you now have a fresh repository ready for action, pulling and pushing to your remote repo at Dreamhost.
How it works
On the server, it creates a folder named git in your home directory – if it doesn’t already exists – and creates a directory named project_name.git in it. It then initializes a bare git repo in that directory, meaning that the repo will hold the git database only, and is not used for doing actual work in.
On your local machine it creates a directory with the project name, initializes a git repo in it, adds an commit an empty .gitignore file to it, and pushes that to the remote repo on your server. Finally it sets up the remote repo to be the default push and pull location for the master branch the local repository. This way, we only have to type git push and git pull without specifying which remote repo and branch we want to interact with.
Hello, I'm Casper Fabricius. I have developed for the web for 9 years, and have been enjoying Ruby on Rails for the past 4.
My experience covers communities, shopping solutions, multi-language sites, heavy back-end lifting and a wide selection of more traditional websites. I like to integrate Ruby with Java and .NET through JRuby and IronRuby when it makes sense. I am passionate about test- and behavior-driven development, but at the same time I am pragmatic and believe in getting things done.
I am based in Copenhagen, Denmark, but I take assignments from across the globe. Feel free to study my resumé, featured projects and - of course - to hire me.
buy paxil canada
buy viagra without a prescription
cheap levitra online
cheap discount soma
buy viagra pharmacy online
cheap discount levitra online
premarin
buy viagra now online
buy legal fda approved viagra
cheaper viagra levitra cyalis
buy medved viagra
discount viagra brand drug
discount viagra in the usa
buy viagra softtabs
buy viagra on line
buy cheap generic viagra
buy online viagra securely
buy viagra next day delivery
cheap online pill viagra
buy lasix
viagra canada prescription
viagra and cialis and
buy discount zoloft
cheap crestor online
buy buy cheap viagra
cheapest price for viagra
cheap pill viagra
buy sildenafil viagra
buy in online uk viagra
cheap cialis viagra
cheap drug retin viagra wellbutrin
order viagra licensed pharmacies online
buy viagra from brazil
cheapsest viagra online
cheap order prescription viagra
buy form generic viagra
buy viagra at safeway
cheap deal discount viagra viagra
cheapest viagra online in the uk
cheapest viagra uk
buy hgh now
buy crestor now
buy viagra in the philippines
buy generic online viagra
cheapest online viagra
order forms for buying viagra
cheapest generic silagra viagra
buy caverta
buy cheap cialis
buy now online viagra
buy cialis canada
buy viagra online 350
order prescription viagra
discount viagra sale
buy viagra from an online pharmacy
order generic viagra
cheap cheap viagra
cheap cheap herbal viagra viagra viagra
viagra by mail order
buy viagra low cost
order viagra usa
cialis 32
buy cheap soma
buy viagra cialis
cheapest viagra in uk cheap
buy online online pill viagra viagra
buy internet viagra
cheap online pharmacy viagra viagra
buy cheap discount levitra
cheap online purchase viagra
buy viagra onlines
buy real viagra pharmacy online
cheapest cialis
buy viagra and cilas usa
buy viagra online order
over the counter viagra in europe
cheap viagra online uk
viagra bullshit
buy viagra online 35008 buy
buy drug satellite tv viagra
viagra breathing
cheap generic india viagra
buy discount viagra online
cialis 1
buy crestor online
discount viagra cialis
buy viagra meds online
buy viagra ups
buy online viagra viagra
soma online
buy generic viagra online pharmacy online
buy viagra online without prescription
cheap viagra kamagra
cheap quality viagra
cheep viagra from indea
buy viagra inte
buy viagra online u
order viagra on line
buy pharmaceutical viagra
viagra and discovery
buy viagra levitra alternative lavitra
cheapest in uk viagra
buy herbal viagra
order viagra onlines
viagra buying online
buy viagra and overseas
buy cheap viagra on the net
cheapest brand viagra
cheap levitra online
buy hgh canada
buy cheap deal pill viagra
order viagra buying viagr
buy plavix
discount viagra generic
viagra buy viagra
buy viagra for cheap
buy viagra in england
buy deal herbal viagra viagra
cheap referrers total viagra
buy cheap cialis generic levitra viagra
order site viagra
cheapest viagra us pharmacy
buy viagra online australia
buy viagra for women
buy kamagra
discount viagra mastercard
cheap discount viagra
cheep generic viagra
buy isoptin
cheap viagra discount viagra buy viagra
buy cialis without prescription
cheap viagra uk
cheapest viagra world
discount viagra viagra
buy viagra in the uk
buy viagra per pill
discount viagra or cialis
cheap overnight viagra
buy viagra now
discount viagra drug
buy lipitor
order order viagra
buy viagra order viagra
discount viagra offers
buy p viagra
cheap kamagra uk viagra
cheapest viagra online plus zenegra
cheap viagra 25mg
buy viagra without prescription
buy in uk viagra
buy generic viagra pharmacy online
buy levitra viagra online
cheap molde ticket viagra
cheapest price viagra
cheapest viagra us licensed pharmacies
viagra and coupon
buy viagra viagra online
order viagra with mastercard
cheap no prescription viagra
cialis online
buy viagra online web meds
viagra buy uk
cheapest price for viagra and cialis
viagra and cialis cheap
generic soma
buy cheao cgeap kamagra uk viagra
buy levitra online viagra
buy prescription viagra without
buy viagra no prescription
buy cheapest online place viagra
buy viagra online online pharmacy
purchase levitra
buy levitra now
purchase levitra online
order levitra online
cheap viagra no presrciption 50mg
buy viagra where
buy online p viagra
buy online purchase viagra
buy viagra 100mg
cheapest generic viagra caverta veega
buy cheap viagra 32
buy online viagra in the uk
viagra by mail
purchase tramadol online
discount viagra prescription drug
buy cheap site viagra
buy viagra zenegra
buy softtabs viagra
over the counter viagra substitute
order viagra online consumer rx
cheap levitra viagra href foro forum
viagra buy it
buy cheap crestor
buy viagra or cilas
order mexican viagra
buy now viagra
buy crestor
buy viagra australia
cheap mexico viagra
buy viagra online india
order viagra online a href
cheap viagra canada
cheapest generic viagra and cialis
buy viagra online no prescription
cialis 20mg
allegra d
cheap deal pill pill viagra
buy viagra online now buy viagra
viagra buy now pay later
buy lexapro
buy viagra alternative
cheap phizer viagra
viagra buy in uk online
order crestor
cheap drug online prescription viagra
generic zoloft
imitrex
buy deal deal price viagra
buy viagra in uk
viagra and deafness
buy viagra cheap through online sales
cheap prescription viagra without
cheap viagra in uk
buy viagra 32
cheap testosterone viagra href foro
buy keyword viagra
order zoloft online
cheap generic viagra substitutes
buy discount soma
buy viagra contact us page
buy canada viagra
buy viagra in mexico
buy australian viagra
cheapest line viagra
order discount viagra
cheap pharmaceutical viagra
order 50mg viagra
viagra buy contest
buy levitra
buy viagra online discount
tramadol cod
cheapest generic viagra and cialis pills
buy viagra online alternative viagra
order crestor online
buy viagra over the counter
buy dot phentermine viagra
buy deal viagra
cheap online generic viagra
buy online sale viagra
buy viagra cheap fed ex
buy avandia
buy glucophage
buy viagra in spain
cheapest prices on generic viagra
buy non prescription generic viagra paypal
zoloft online
cheap meltabs viagra
buy cheap discount lexapro
order viagra softtabs
buy viagra buy cheap viagra index
buy cipro
cheap genric viagra online
generic levitra
buy viagra toronto
cheaper viagra
buy depakote
buy free viagra viagra
buy cheap uk viagra
viagra buy general
cheap viagra cialis
cheap discount soma online
cheap generic viagra from usa
purchase crestor online
buy cheap discount pill viagra viagra
seroquel
cheapest viagra on line
buy viagra safeway pharmacy
buy cheap viagra online uk
cheap soft tab viagra
order status viagra
cheap testosterone viagra href foro forum
cheap drugs viagra cialas
buy now soma
buy crestor
cheap discount cialis
order pfizer viagra with mastercard
cheap viagra credit
cheapest generic substitute viagra
viagra buy australia
cheap viagra online order viagra now
buy viagra in bangkok
buy viagra over the counter us
buy cheap viagra online now uk
buy cheap purchase uk viagra
cheapest viagra and regalis
cheapest generic viagra 99 cents
buy cailis viagra singapore
cheapest viagra prices uk
cheap crestor
purchase crestor
order viagra prescription
viagra and flomax
buy followup post viagra
buy generic viagra online
buy online online viagra viagra
viagra buy
purchase paxil online
order viagra now
cheap viagra
buy carisoprodol no prescription
purchase nexium online
order viagra online in wisconsin
buy in spain viagra
cheap viagra index
over the counter viagra alternative
buy sublingual viagra on the internet
buy imitrex
order viagra overnight shipping
cheap viagra online prescription
buy cheap p viagra
buy viagra with paypal
viagra canada price
buy viagra line
cheap cheap viagra viagra
buy viagra in london
viagra by money order
discount viagra overseas
viagra by phone
buy viagra in toronto
buy cheap levitra
cheapest place to buy viagra online
check generic order pay viagra
buy uk viagra
cheap viagra from pfizer
buy online pill viagra
buy generic viagra si br
buy pill price price viagra
buy generic viagra usa
cheap gerneric viagra
buy cheap online prescription viagra
cheaper viagra levitra apcalis
buy cheap viagra online here
buy viagra phentermine online pharmacy
buy discount price sale viagra viagra
buy discount crestor
buy viagra online cheap
viagra buy do nu
buy viagra by pill
over the counter viagra
buy cheap viagra online now
buy evista
cheap herbal sale viagra viagra
buy cheap lexapro
buy viagra online 35008 buy viagra
buy viagra without prescription pharmacy online
lexapro side effects
buy cheap free online viagra viagra
buy cheapest viagra
cheap discount levitra
cipro 20
cheap viagra fast shipping
relafen
buy online prescription viagra without
buy can reply viagra
buy site viagra
cheap deal viagra
buy online order viagra
cheapest uk supplier viagra
buy viagra in amsterdam
cheapest viagra in uk che
buy cheap sale viagra
order viagra online no rx prescription
buy soma
discount viagra
buy diet viagra online
buy neurontin
buy viagra new york
buy now hgh
cheap discount crestor online
buy online viagra viagra viagra
cheap paxil online
buy levitra canada
buy prescription viagra
discount viagra perscription drug
cheap herbal viagra viagra viagra
buy cheap online uk viagra
buy viagra in united kingdom
buy cheap viagra viagra
buy coumadin
viagra and cialas
cheapest viagra on the internet
cheap discount crestor
cheapest generic viagra sent overnight
buy viagra online get prescription
buy locally viagra
viagra by mail catalog
cheapest viagra overnight
Jesper
September 22nd, 2008 at 1:21 pm
Hvorfor Git? Jeg er med på at decentralizeret source control er skidesmart, men nogen speciel grund til at du bruger lige præcis Git?
Jeg har selv leget noget med Bazaar, og må indrømme jeg er ret imponeret over det.
Casper Fabricius
September 22nd, 2008 at 1:26 pm
Haha, faktisk mest fordi hele Ruby on Rails communitiet er hoppet på git-vognen, så det er det mest praktiske for mig ;)
Jamie Hill
October 4th, 2008 at 1:29 pm
Great write-up. Could you briefly explain the line: “merge = refs/heads/master” in the .git/config file?
Thanks again.
Casper Fabricius
October 5th, 2008 at 8:44 pm
Hi Jamie,
Thanks. As I say in the article, I’m no git expert, but I’m pretty sure it means something like “when I pull, take the remote branch called master, and merge it into my master branch.”
Git Publishing (rgit): Paranoia, Syndication, Transparency < expatiari expatria
November 24th, 2008 at 2:11 am
[...] Casper Fabricius [...]
Alex Genaud
November 24th, 2008 at 2:48 am
I see you’ve gotten the ping. Hey, Casper, I took your script and ran with it. Tak skal du have.
Casper Fabricius
November 24th, 2008 at 10:24 am
Det var så lidt – you are welcome :)
Using GIT version control system » Autarchy of the Private Cave
December 25th, 2008 at 11:19 pm
[...] setting up Git repository on Dreamhost (also: hosting Git on Dreamhost; in the light of GoDaddy now offering SSH access for shared hosting plans, instructions for Dreamhost get even more value.) [...]
AdamV
January 6th, 2009 at 9:24 am
Casper,
This is great! Now by any chance are you going to update your install radiant to dreamhost via capistrano to use GIT?
Casper Fabricius
January 12th, 2009 at 8:37 pm
Hi Adam,
Good idea – I’ll probably get around to that sometime soon. I have a working deploy script for git, so it shouldn’t be too much effort :)
Fred
February 9th, 2009 at 4:08 am
I second the idea of a new tutorial for Radiant particularly since a new version is out.
Thanks for your blog.
A Git workflow for single developers - cakebaker
March 8th, 2009 at 12:04 pm
[...] want to avoid typing the SSH password every time you push data, create a public/private key set as described by Casper [...]
Adam V
March 14th, 2009 at 12:51 am
A quick note…
When using this technique with Capistrano, I was always getting password requests. So I had to generate an RSA key on my dreamhost account and add it to the authorized keys of the same account.
A little silly but it worked.
Casper Fabricius
March 14th, 2009 at 10:27 am
Hi Adam. Thanks for the note – not silly at all. Actually I believe that is exactly what I describe in the section titled “Create and add your public key (optional)” – unless I misunderstand you?
Christopher Warren
March 22nd, 2009 at 12:26 am
I’ve created a Rails Template for Rails 2.3 that recreates your dreamgit script at http://github.com/chriswarren/rails-templates/tree/master. It also lets you set up Capistrano to deploy to Dreamhost (or any other host) using the newly created repository.
Casper Fabricius
March 22nd, 2009 at 11:58 am
Hi Christopher. Very nice. Rails templates are definitely a good way to share all these tools and recipes we usually just copy from blogs, pasty and so on. I’ll have to start making some of them myself soon :)
Instalación y configuración del Servidor y Cliente Git bajo ssh « Frameworks Agiles
March 23rd, 2009 at 11:51 pm
[...] http://casperfabricius.com/site/2008/09/21/keeping-git-repositories-on-dreamhost-using-ssh/ [...]
A Git workflow for single developers | linkfeedr
April 12th, 2009 at 10:44 pm
[...] want to avoid typing the SSH password every time you push data, create a public/private key set as described by Casper [...]
Stoney’s Zone » Mirroring git respositories to DreamHost
June 11th, 2009 at 10:16 pm
[...] Fabricius has a nice shell script for creating new git repositories on DreamHost. Unfortunately, this works only for creating new [...]
Remy Giard
September 1st, 2009 at 5:16 am
Nice script and works wells.
Note that to have multiusers support for git repositories on dreamhost, we may run “git repo-config core.sharedRepository group” just after “git –bare init”. Else, the git internal files will get the rights of the committing user and this will be a problem for other users. So this could be added to the “ssh” line of your script.
More info can be found at:
http://bob.zoller.us/post/41707381/shared-git-repo-using-ssh-transport
Remy Giard
Casper Fabricius
September 11th, 2009 at 4:54 pm
Hi Remy. Thank you for that great tip!
Stephen A. Goss
November 2nd, 2009 at 11:31 am
I couldn’t get the passwordless ssh login to work with your instructions. You have to make sure the ~/.ssh/authorized_keys file has the proper permissions. See here : http://wiki.dreamhost.com/Ssh#Passwordless_Login
Casper Fabricius
November 2nd, 2009 at 11:36 am
Thank you for the tip, Stephen :)
Tadd Giles
February 7th, 2010 at 6:06 am
Let me add my thanks as well. Just what I needed this evening. Cheers!
Git on Dreamhost « selene tan
March 7th, 2010 at 2:12 am
[...] Fabricius’ Keeping git repositories on Dreamhost using SSH has some instructions and a handy script for automating the process. Thing is, I tend to create the [...]