git is NOT ignoring a symlink

不想你离开。 提交于 2019-12-13 20:02:32

问题


I have a git project which has a subdirectory at /application/assets, and a symlink pointing to it at /assets

"assets" is in the .gitignore file in the root directory, but about one in three times, when I "git pull" on production, the symlink is overwritten with the path of my development environment.

What can I do to make sure git always ignores that symlink? Or is there a way to make it always point to a relative path (application/assets) instead of the full path on my dev machine?


回答1:


.gitignore doesn't come into play in a pull or merge. .gitignore only affects untracked files. If the file is in a commit, it's no longer untracked.

In one of the commits you are pulling it, someone committed the file you wanted to leave untracked, and thus, you will receive that file when you pull that commit.

Delete the file from the repository, and it will become untracked again.




回答2:


Are you sure that the symlink hasn't been committed in production? That behaviour sounds like it is.

.gitignore will ignore files/dirs in your working directory, I don't think it will exclude them from being overwritten.



来源:https://stackoverflow.com/questions/7492315/git-is-not-ignoring-a-symlink

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