A workaround would be to have /srv/www/projectfiles be a symlink to /home/me/code/project/static so git sees no symlinks
If you are using linux, I particularly like the solution provided by GitBLSR. It is a library that is loaded via LD_PRELOAD that transparently dereferences symlinks to files and folders outside a repository.
To install it for a local user account is simple:
git clone https://github.com/Alcaro/GitBSLR.git cd GitBSLR ./install.sh
This will compile the library and create an alias like the following in
alias git="LD_PRELOAD=/path/to/gitbslr.so git"
Using this alias enables the transparent link dereferencing.
Consider using a mount point to mount the destination folder (which you presently symlink to) to appear in the location you want it beneath the git project. I’ve used this approach successfully.
#!/bin/sh sudo mount --bind ./src_folder ./dst_folder
Another workaround – the only one I found that works for directories too – is to change git working tree for the specific actions.
git --work-tree=/home/me/code/project/ add /home/me/code/project/static/ git --work-tree=/home/me/code/project/ commit /home/me/code/project/static/
Move the files into the folder and remove the symlink. Git doesn’t traverse symlinks.
It (and I) would assume that you are symlinking to a set of files that you either don’t control or don’t want to modify, as such they don’t need to be versioned.
rsync <folder_out_of_git_repo> <folder_in_git_repo> before
git add && git commit.
I had the same problem… Uploading a directory with symlinked files into a GIT repository, for public release.
The GIT repository is secondary source, not the primary source of the files, as such I do not want to replace the symlinks on my local machine. Hardlinks are no good as these get broken, and it is not obvious when looking that they are links.
My solution script was posted here…