简体   繁体   English

git - 如何不签出文件或文件夹

[英]git - How to Don't checkout a file or folder

We have a repo.我们有一个回购。 A coworker check in a folder in linux.一位同事在 linux 中签入一个文件夹。 I want to check it out in Windows.我想在 Windows 中查看它。 There are some filenames(eg ABC::DEF.3pm.gz) what Windows doesn't.有一些 Windows 没有的文件名(例如 ABC::DEF.3pm.gz)。 It fail when I run当我运行时它失败了

git pull origin git pull 原点

Is there a way to ignore this folder?有没有办法忽略这个文件夹?

I've tried put this folder in .gitignore and it doesn't work as this folder's already in repo.我试过把这个文件夹放在 .gitignore 中,但它不起作用,因为这个文件夹已经在 repo 中了。

There are two possible solutions.有两种可能的解决方案。

Sparse checkout稀疏结帐

Sparse checkout is a Git feature which allows to checkout only specific files and directories.稀疏检出是 Git 的一项功能,它允许仅检出特定的文件和目录。 See examples and further discussion here .请参阅此处的示例和进一步讨论。

Filter-branch过滤器分支

Another solution would be renaming that file across whole repository with git filter-branch as described in this answer.另一种解决方案是使用git filter-branch在整个存储库中重命名该文件,如答案所述。 That would help to get rid of issue at all, however it would also rewrite commit history.这将有助于彻底摆脱问题,但它也会重写提交历史。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM