简体   繁体   中英

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.

We're developing with Xamarin and we would like to ignore the packages/ folder except one file which is placed in different (sub)directories.

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.

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.

But I think that you have to remove packages in the remote before adding packages to your .gitignore file by command:

git rm --cached packages
git push origin master

And make sure that .gitignore is located same parent directory with packages

In the better way, I think you should create a .gitignore located in packages with the content:

*
!SQLitePCL.raw_basic.0.8.2/build/Xamarin.iOS10/SQLitePCL.raw_basic.targets
!.gitignore

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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