简体   繁体   中英

Git ignore directory not working on .vs directory

I'm having issues getting git to ignore the .vs hidden directory in my project. I have the following structure, all my project files are in the MyProject directory, which also includes the .vs directory, which I'm trying to ignore.

root/.git
root/MyProject
root/.gitattributes
root/.gitignore

root/MyProject/.vs

I've tried adding a bunch of ignore commands to the .gitignore file but none seem to work. I've tried using

*.vs
*.vs/
*.vs/*
**/.vs
**/.vs*
**/.vs**
**/.vs/**
**/.vs/*
MyProject/*.vs
MyProject/*.vs/
MyProject/*.vs/*
MyProject/**/.vs
MyProject/**/.vs*
MyProject/**/.vs**
MyProject/**/.vs/**
MyProject/**/.vs/*

I just want all files in the .vs file to be ignored.

Please assist.

.vs should do. Just in case: adding stuff into .gitignore , if the files are already tracked, it won't work. It will only work for files that are untracked.

Now, if you already are tracking stuff in .vs and you would like to not do it, then you can use two approaches:

  • git rm --cached .vs

This will get rid of the .vs directory for the revisions moving forward , it won't touch the files as you have them on the working tree. This also means that if, say, in a year you want to come back to one of the revisions that already contain those files, you might overwrite the content of the files as you have them at that moment in time potentially busting whatever thing depends on that metadata.

  • git filter-branch or filter-repo

These are tools that can rewrite the history of the branches so that the .vs directory is taken out of it completely. This is like pulling the big guns and it shouldn't be taken lightly because it means overwriting history... with all of its implications (way outside of the scope of this answer to detail). Just in case, filter-branch is getting phased out and filter-repo is a script that is still not inside git, if I'm not wrong.

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