Under linux, I used
mount --bind olddir newdir to link a source code directory from a git repository in my Dropbox folder to another public git repository. I did this to avoid using git submodules and, for whatever reason, git had trouble following hard links under Ubuntu.
I recently purchased a Macbook Pro, and I was trying to use the same bound mount point. The mount provided with OS X doesn’t offer
--bind. A main suggestion I found online is to use bindfs. bindfs didn’t work for my needs, and I didn’t want to manually compile a link/unlink application as others suggested.
I found that the homebrew package coreutils provides the gnu version of
ln. To install:
brew install coreutils
This package doesn’t overwrite OS X default packages unless you run the above command with the
--default-names switch, otherwise all utilities are prefixed with a g. Using the gnu ln program, I was able to hard-link successfully:
gln -d src target
I don’t know what the difference is between Ubuntu and OS X (both running git 1.8.4), but I can now work properly under git with hard links as expected.
Installing more gnu utilities
You can go one step further and install more gnu utilities (found on StackExchange):
brew install coreutils findutils gnu-tar gnu-sed gawk gnutls gnu-indent gnu-getopt
Then, add the following to your .bashrc:
Thanks to the Apple StackExchange user lri for the excellent post.