git commit symlink as a regular file

If you want the file to appear instead of the link, you should probably use the ln command to create a hard-link instead of a sym-link (ln -s).

Making a hard-link, you can make the same file to appear under two different directories, so changing it via any of the links will reflect changes via both links, and the file will live in both directories, so it will be tracked by git.

I hope Windows' mklink /j command in Bukov's answer does this, but I really don't know at all.


Nope, Git knows it's a symlink. It'd be kind of dangerous for Git to pretend otherwise, since it would then end up writing to files outside the repo. Tracking it as a symlink is exactly the intended behavior.


In Windows, you can do what you want with a Junction

For example, programs often keep a settings file somewhere on the system, but I'd like to version control it in my repository. I can't move the file, and I don't want to make duplicates or anything

If we put a Windows Shortcut in the repository directory though, he'll see it as a binary single file; not a directory pointing to all the actual files you want to include

What we need is the ability to put something like a Windows shortcut in the repository, but that git will treat as just another folder:

cd /location/of/my/repo/  
mklink /j "_linkTo_VimSettings" "C:\Program Files (x86)\Vim"

Tags:

Git

Symlink