[英]Make .gitignore ignore everything except one file
I'm pretty new with the whole .gitignore thing so I hope someone can help me out with this. 我对整个.gitignore事情还很陌生,所以我希望有人可以帮助我解决这个问题。
We're developing with Xamarin and we would like to ignore the packages/ folder except one file which is placed in different (sub)directories. 我们正在使用Xamarin进行开发,除了一个文件放在不同(子)目录中之外,我们想忽略packages /文件夹。
I would like to keep the following file: 我想保留以下文件:
/packages/SQLitePCL.raw_basic.0.8.2/build/Xamarin.iOS10/SQLitePCL.raw_basic.targets
But all the other folders and files inside /packages/ I would like to be removed. 但是/ packages /中的所有其他文件夹和文件我都希望删除。
I tried something like: 我尝试了类似的东西:
packages/
!packages/SQLitePCL.raw_basic.0.8.2/build/Xamarin.iOS10/SQLitePCL.raw_basic.targets
But I don't think this is the way to go. 但是我不认为这是要走的路。
I think that your .gitignore
file is correct. 我认为您的
.gitignore
文件是正确的。
But I think that you have to remove packages
in the remote before adding packages
to your .gitignore
file by command: 但是,我认为你必须删除
packages
将之前在远程packages
到您.gitignore
的命令文件:
git rm --cached packages
git push origin master
And make sure that .gitignore
is located same parent directory with packages
并确保
.gitignore
与packages
位于同一父目录中
In the better way, I think you should create a .gitignore
located in packages
with the content: 以更好的方式,我认为您应该在包含以下内容的
packages
创建一个.gitignore
:
*
!SQLitePCL.raw_basic.0.8.2/build/Xamarin.iOS10/SQLitePCL.raw_basic.targets
!.gitignore
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.