[Daniel] Serving Git From Mac OS X
I'm running Git built from source on Mac OS X 10.5. I've been trying to migrate from Subversion to Git for awhile now but always got hung up on how to host the "repository". My ideal was to push to a bare repository in the style of Subversion and be able to pull from it elsewhere. The problem lies in wanting to how it on my laptop.I beat my head against the following error message for a good hour: "bash: git-upload-pack: command not found". None of the documentation I stumbled across seemed very helpful. Then it occurred to me that it might be a path issue, as Git seems to install to "
/usr/local/bin" by default.
The solution (provided you've built Git correctly with a standard "configure/make/make install") looks something like this:
- Within your project, create a bare repository (i.e. "
git clone --bare -l . /Users/daniel/git/project.git"). - Inform Git the project needs to be servable (i.e. "
git --bare --git-dir=/Users/daniel/git/project.git update-server-info"). - Create (or edit) a "
.bashrc" file in your home directory. Prepend on the "/usr/local/bin" directory to the PATH (i.e. "export PATH=/usr/local/bin:$PATH"). - On a remote server, clone the project. I like SSH so running that would look like "
git clone ssh://daniel@domain.dyndns.org/Users/daniel/git/project.git project".
Note that the path to the Git repository is absolute. I created a "git" folder in my home directory for storing all the Git repositories in one place.
Comments
I was pulling my hair out over this too. I found that all I had to do was the following:
1) For me, Git is installed in /usr/local/git/bin, so I added the following to my .bash_profile:
GIT=/usr/local/git/bin
export PATH=$GIT:/usr/local/bin:/usr/local/sbin:$PATH
2) After reading this ->(http://cururudobrejo.com/2008/04/02/bash-git-upload-pack-command-not-found/), I symlinked .bashrc to .bash_profile:
ln -s .bash_profile .bashrc
And now it works!
Your post helped me to solve my problem. My git came from macports, so what did it for me was the .bashrc line
<tt>PATH=/opt/local/bin:$PATH</tt> because that's where macports puts the binaries.
My repo is not bare and it works too.
The bare portion is not a requirement. It simply saves on unnecessary files (as it does not check out a working copy, just the git database). Any git repository, bare or not, can be used as a source for cloning.

