简体   繁体   English

Git忽略目录不适用于.vs目录

[英]Git ignore directory not working on .vs directory

I'm having issues getting git to ignore the .vs hidden directory in my project.我在让 git 忽略项目中的 .vs 隐藏目录时遇到问题。 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.我有以下结构,我所有的项目文件都在 MyProject 目录中,其中还包括 .vs 目录,我试图忽略它。

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.我试过在 .gitignore 文件中添加一堆忽略命令,但似乎都不起作用。 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.我只想忽略 .vs 文件中的所有文件。

Please assist.请协助。

.vs should do. .vs应该做。 Just in case: adding stuff into .gitignore , if the files are already tracked, it won't work.以防万一:将内容添加到.gitignore ,如果文件已经被跟踪,它将无法工作。 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:现在,如果您已经在.vs中跟踪内容并且不想这样做,那么您可以使用两种方法:

  • 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.这将删除 .vs 目录以用于向前推进的修订,它不会触及工作树上的文件。 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 git filter-branchfilter-repo

These are tools that can rewrite the history of the branches so that the .vs directory is taken out of it completely.这些是可以重写分支历史记录的工具,以便将 .vs 目录完全取出。 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.以防万一,filter-branch 正在逐步淘汰,filter-repo 是一个仍然不在 git 中的脚本,如果我没记错的话。

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

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