[英]How to get Git on Windows to ignore symbolic links
I can't get this to work.我无法让它工作。
I have cloned a repository that has a dummy file (named src): /path/src
.我克隆了一个包含虚拟文件(名为 src)的存储库: /path/src
。
On Windows I have created a symbolic link: mklink -d /path/src /otherplace/src
(but I of course had to delete the dummy src file first).在 Windows 上,我创建了一个符号链接: mklink -d /path/src /otherplace/src
(但我当然必须先删除虚拟 src 文件)。
In both my .gitignore
and .git/info/exclude
I have在我的.gitignore
和.git/info/exclude
我有
/path/src/
/path/src
path/src/
path/src
And I have tried我试过了
git ls-files -s | gawk '/120000/{print $4}'
git update-index path/src/ --assume-unchanged
but I still get:但我仍然得到:
error: readlink("path/src"): Function not implemented
error: unable to index file path/src
fatal: updating files failed
I have tried all these other suggestions .我已经尝试了所有这些其他建议。 And even this doesn't work .即使这样也行不通。
Any ideas?有任何想法吗?
You can do a checkout ignoring this single file like this:您可以执行忽略此单个文件的结帐,如下所示:
git checkout HEAD . --no path/src
The .gitignore
file only works for adding stuff to the index. .gitignore
文件仅适用于向索引添加内容。 Even a modifications on files commited before adding it to the .gitignore
are not ignored.即使在将文件添加到.gitignore
之前提交的文件修改也不会被忽略。
I know this is late, but I ran into this issue.我知道这已经晚了,但我遇到了这个问题。
In my case, I apparently had checked in my symlink at some point.就我而言,我显然已经在某个时候检查了我的符号链接。 So no matter what I did, .gitignore
would not work (I think that is what Alexandre was getting at).所以无论我做什么, .gitignore
都不起作用(我认为这就是 Alexandre 的意思)。
REPAIR:修理:
Now you can re-add your symlinks and .gitignore
should work.现在你可以重新添加你的符号链接, .gitignore
应该可以工作了。
Here are my steps for this issue, similar, but a bit different from other answers.这是我针对此问题的步骤,类似但与其他答案有所不同。
Let's say I had a folder .fvm
contain file.json
and flutter_sdk(link)
that all commited in git before, then I want to ignore out flutter_sdk
.假设我有一个文件夹.fvm
包含file.json
和flutter_sdk(link)
之前都在 git 中提交,那么我想忽略掉flutter_sdk
。
.fvm/flutter_sdk
and .fvm/flutter_sdk/
in .gitignore
.在.gitignore
中添加.fvm/flutter_sdk
和.fvm/flutter_sdk/
。.fvm/flutter_sdk
out to other place than the repository.将.fvm/flutter_sdk
剪切到存储库以外的其他地方。git add.
and git commit....
和git commit....
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.