I have some symlinks in my git repo which I work on from two machines (say A and B.) Both run Linux, but B is run through VirtualBox and the file system is shared from the Win7 host system. Thus, B does not support symlinks.
When doing some work on B I realized that using symlinks was a bad idea in my case. So on B I copied all the targets so that they’d overwrite the “symlinks.” Then I’d commit this, push it to my central repo, and then pull it on A.
The problem is on A where the files now have the permission of symlinks, but with the contents of the file. E.g. if the original file was a text file containing “Lorem ipsum dolor sit amet …” then the symlink would on A now point to the nonsensical path ‘Lorem ipsum dolor sit amet …’ and all file operartions on it would fail.
Example (to start with, foo.png is a symlink to ../bar.png, both are in the repo):
user@B> cat foo.png
../bar.png
user@B> cp ../bar.png ./foo.png
user@B> git add foo.png
user@B> git commit -m "Removed symlink"
user@B> git push
…
user@A> git pull
user@A> ls -l foo.png
lrwxrwxrwx 1 user user 8 2012-06-22 15:13 foo.png -> ?PNG????
user@A> git status foo.png
# On branch master
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: foo.png
#
I couldn’t figure out any way to remove the symlink flag from the files or do a checkout as normal files and I hope someone can help.
Should anyone else have this problem I found that the quick and dirty (and obvious) solution is:
When you stage the files to commit they will be marked with