Archive

Posts Tagged ‘leopard’

Using a webdav git repository on Leopard

February 17th, 2009 No comments

This howto should clarify how to use git as a versioning system on a mac.  We use a git repository that has bee installed as described in my previous how to. This how to is strongly based on this kernel.org howto.

First we have to setup our environment, assuming that you have macports installed:

sudo port selfupdate
sudo port install git-core

Now we add our user and host to our .netrc file, to avoid repeated authentication:

vim ~/.netrc

Add the following information to this file:

machine <servername>
login <username>
password <password>

Now set the proper permissions:

chmod 600 ~/.netrc

Now we can create our local git repository, first we add a folder somewhere in our file system:

cd
cd Documents
mkdir my-new-repo.git
cd my-new-repo.git

Before we actually initialize our repository you can add some global info about you to the git environment:

git config --global user.name "Your Name Comes Here"
git config --global user.email you@yourdomain.example.com

You have to add some initial files, by copying them in to:

~/Documents/my-new-repo.git/

And now we initialize our git repository:

cd ~/Documents/my-new-repo.git
git init

Now we can add and commit our files into the repository, you may know this concept from svn:

git add .
git commit

And now the interesting part, interaction with the webdav server, first we have to configure the access:

git config remote.upload.url \

http://<username>@<servername>/my-new-repo.git/

Attention: Keep the trailing slash!

Now we can do the initial push, as you may have noticed commit didn’t send data to the server, as you would have expected it from svn for example. Instead push does.

git push upload master

Hey now there is some data on the server! But probably we want do get data from the server as well, here we can use the pull command:

git pull upload master

But it fails… we have to switch to the server and run the following command in the repository directory:

cd /var/www/my-new-repo.git
git-update-server-info
chown -R www-data.www-data ../my-new-repo.git

It’s a bit strange, but… why not. Now we can pull from our Mac:

git pull upload master

If you initialized the repository others can just clone it, this is an example of cloning:

cd
cd Documents
git clone http://<username>@<servername>/my-new-repo.git

A quick note, if you want to install git on Windows you can use msysgit on linux the setup should be almost the same.

Some Links
tortoisegit
Git on windows
Git on Windows (kerneltrap.org)