Search code examples
gitsymlink

How can I get Git to follow symlinks?


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.


Solution

  • NOTE: This advice is now out-dated as per comment since Git 1.6.1. Git used to behave this way, and no longer does.


    Git by default attempts to store symlinks instead of following them (for compactness, and it's generally what people want).

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

    I.e.:

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

    by doing

     git add /bar/foo/baz
    

    it appeared to work when I tried it. That behavior was however unwanted by me at the time, so I can't give you information beyond that.