git commit symlink as a regular file

做~自己de王妃 提交于 2019-12-03 22:06:26

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.

mgarciaisaia

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.

Bukov

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"
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!