views:

4388

answers:

5

I've had a google for how to do this, but not had any luck.

Is my best be going to be a shell script which replaces symlinks with copies, or is there another way of telling git to follow symlinks?

PS: I know it's not very secure, but I only want to do it in a few specific cases.

+9  A: 

Git by default attempts to store symlinks instead of following them ( for compactness and its generally what people want )

However, i accidentally managed to get it to add files beyond the symlink when the symlink is a directory.

ie:

  /foo/ 
  /foo/baz
  /bar/foo --> /foo 
  /bar/foo/baz

by doing

 git add /bar/foo/baz

appeared to work when i tried it, that behavior was however unwanted by me at the time, so I Cant give you info beyond that.

Kent Fredric
didn't work for me on osx. says " is beyond a symbolic link"
Yar
The commits 725b06050a083474e240a2436121e0a80bb9f175 and 806d13b1ccdbdde4bbdfb96902791c4b7ed125f6 introduced changes that stopped you adding files beyond symlinked directories, so this won't work in versions of git since 1.6.1
Mark Longair
+3  A: 

I used to add files beyond symlinks for quite some time now. This used to work just fine, without making any special arrangements. Since I updated to git 1.6.1, this does not work any more.

You may be able to switch to git 1.6.0 to make this work. I hope that a future version of git will have a flag to git-add allowing it to follow symlinks again.

-erik

Erik Schnetter
A: 

I'm using git 1.5.4.3 and it's following the passed symlink if it has a trailing slash. E.g.

# adds the symlink itself 
$ git add symlink 

# follows symlink and adds denoted directory's contents
$ git add symlink/
at least on OSX this results in `fatal: 'src/' is beyond a symbolic link`
Yar
+1  A: 

what i did to add to get the files within a symlink into git (i didn't use a symlink but):

sudo mount --bind SOURCEDIRECTORY TARGETDIRECTORY

do this command in the git managed directory. TARGETDIRECTORY has to be created before the SOURCEDIRECTORY is mounted into it.

works fine! that trick helped me with subversion too. i use it to include files from an Dropbox account, where a webdesigner does his stuff.

A: 

hmmm mount --bind doesn't seem to work on Darwin.

Does anyone have a trick that does?

[edited]

OK I found the answer on OSX is to make a hardlink. Except that that API is not exposed via ln so you have to use your own tiny program to do this. Here is a link to that program:

http://stackoverflow.com/questions/1432540/creating-directory-hard-links-in-macos-x

Enjoy!

J Chris A