Git
From DreamHost
Git is a version control system. This page explains how you can host Git repositories on your Dreamhost account.
Note: Dreamhost does not officially support git, if you're interested in git-daemon, you might want to vote for Git support.
Contents |
[edit] Setup One
[edit] Setup a WebDAV directory
Go to panel.dreamhost.com, select "Goodies" and then "Htaccess/WebDAV"...
Create a directory to store your git repository at http://yourhostname.com/git (or git.yourhostname.com/project, or wherever). Make sure to add at least one username/password so you can upload to this directory.
While the DreamHost servers set up WebDAV, proceed to the next section.
[edit] Install Git on your local machine
- Compile it yourself
> wget http://kernel.org/pub/software/scm/git/git-1.5.4.tar.bz2 > tar xjvf git-1.5.4.tar.bz2 > cd git-1.5.4 > make prefix=/usr all doc > su > make prefix=/usr install install-doc > exit
- or get an RPM from kernel.org
- or search for Git at rpmfind.net (don't get GNU Interactive Tools).
[edit] Tell Git who you are
> git repo-config --global user.name "Your Name" > git repo-config --global user.email yournick@yourmailserver.com
[edit] Prepare a Git repository
> mkdir test-repo > cd test-repo > git --bare init-db
Now tell the repository where it will live (needed since WebDAV will be updating the repository).
> git-repo-config remotes.origin.url http://yourhostname.com/git/test-repo/ > git-update-server-info
(Note: the trailing '/' is VERY IMPORTANT)
[edit] Upload to WebDAV
[edit] KDE
- Point konqueror to webdav://yourserver.com/git
- Log in using a username/password you registered with DreamHost
- Copy test-repo into the WebDAV folder
[edit] OS X
- Finder -> Connect to server
- Connect to http://yourserver.com/git
- Copy test-repo into git
[edit] Locally store your username/password
- By doing this, Git won't prompt you for them every time you sync with the WebDAV repository.
- Skip this step if security is a concern.
- Edit ~/.netrc
- Add a line like "machine yourhostname.com login <USERNAME> password <PASSWORD>"
[edit] Create and push a local repository
- Initialize the repo
> mkdir source-repo > cd source-repo > git init
- Add a file
> echo "This is a file" > a.file > git add a.file > git commit
(Note: this opens the vi editor; press ESCAPE then "i" to enter "insert" mode and type some text; then type ESCAPE ":w" ENTER ":q" ENTER to save and exit.)
- Tell this new repo about the server
> git-repo-config remote.upload.url http://yourhostname.com/git/test-repo/
(remember the trailing '/')
- Upload the changes
> git push upload master
- You can download changes using `git pull upload master`
[edit] Pull the WebDAV repository
- "Clone" the repository
> git clone http://yourhostname.com/git/test-repo/
- Look at its history
> cd test-repo > git log
(arrows to scroll, 'q' to quit)
- Add a file
> echo "another file" > b.file > git add b.file > git commit
- Upload the changes
> git push origin master
- You can download changes using `git pull origin`
[edit] Setup Two
If Setup One does not work for you, there is a different way to get it working on DreamHost. This is why Setup Two(http://stevemilner.org/blog/2007/06/24/git-dreamhost/) was created.
If you have trouble with the first one, try the steps in here: http://www.kernel.org/pub/software/scm/git/docs/howto/setup-git-server-over-http.txt for troubleshooting. Especially stuff like making sure your .netrc is working with DAV by testing with curl.
[edit] Instructions
Here is a different methodology for using Git on DreamHost, using davfs2, fuse and git.
First, setup webdav on your DreamHost account for a directory. There is no need to password protectir from being viewed over http (unless you don't want people to easily see your code). You do, however, need to make sure to setup users and passwords for editing. It takes about 1 hour for the changes to go into effect ....
You must have fuse installed. You will probably have to install fuse-devel and neon-devel followed by rebuilding fuse-davfs2 rpm.
Once you have installed fuse-davfs2, mount it just like any other filesystem: mount.davfs http://git.yourdomain.tld/git/ /mnt/git/
If you keep your code in ~/code/ as a git repo, you can clone it on to the /mnt/git/ file system: cd /mnt/git; git clone --bare ~/code/; git-update-server-info
After doing that, you should be able to push and pull from the repo ... pushing to it via the local fs, and pulling from local fs or http url. Congrats ... you now have a public Git repo!
[edit] Setup Three
There is a third, more complex way to use git on DreamHost. wget a git tar ball, build it, and install it. This will involve getting other things like autotool, libcurl, etc. Use this git to pull down the latest git from the main git repository. Build again but do it this time like this: make NO_MMAP=1. That will turn off git's use of mmap. Without doing this the DreamHost autopolice (procwatch) will kill your git processes all of the time because of their "excessive" memory consumption. Git processes really aren't using 500MB of memory, they just have two 250MB files mmaped. But DreamHost doesn't make the distinction and will zap the process. Make sure git is on your shell path and working.
Set up your shell account to use use ssh keys and not need a password. On your local git repo add an entry for your DreamHost repository.
[remote "yourdomain"]
url = ssh://youruser@git.yourdomain.tld/~/projects/yourdomain-kernel.git
fetch = +refs/heads/*:refs/remotes/dreamhost/*
push = refs/heads/*
git push your repository to DreamHost. Use a link to make sure your web server can see the repository. Use git clone to get it back with an http url: http://git.yourdomain.tld/projects/yourdomain-kernel.git
If your are working on the kernel, the set up is more complex. First clone a copy of the kernel from kernel.org. Then rename it to your repo name and push your changes to it (you'll have to futz with master). This will result in the generic kernel ending up in a giant pack file and your changes in loose objects. Now you can use this trick.
git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git yourdomain cd yourdomain git config remote.origin.url http://git.yourdomain.tld/projects/yourdomain-kernel.git git pull
Cloning from kernel.org is about 100x faster than cloning from DreamHost. Without doing this trick it takes an hour to do a clone from git.yourdomain.tld.
Of course, there are about 100 steps omitted in this explanation, but it should give your an idea of how things work. Things would be a lot simpler if DreamHost would install a copy of git and mark it so that autopolice (procwatch) doesn't keep killing it. If things don't work at first, don't give up. This configuration does work but it can take a bit of effort and persistence to get it all sorted out.
[edit] Examples
- Hosting a git repository on dreamhost -- Here's how I did it. -- Dagolden

