Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have two folders:

  • /home/me/code/project/
  • /srv/www/projectfiles/

In the /home/me/code/project folder, I have symlinked static to /srv/www/projectfiles/

i.e. /home/me/code/project/static/ -> /srv/www/projectfiles/

When I try to commit now, it doesn't see any of the files behind the symlink, and instead tries to commit the symlink itself as a file.

How do I commit a file (e.g. /srv/www/projectfiles/style.css)s that is behind the symlink?

share|improve this question
up vote 4 down vote accepted

A workaround would be to have /srv/www/projectfiles be a symlink to /home/me/code/project/static so git sees no symlinks

share|improve this answer

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.

share|improve this answer
I do control these files. They are the stylesheets etc. and need to be in a directory which the server will server. – Macha Aug 11 '10 at 19:13

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.

share|improve this answer

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/
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.