简体   繁体   English

Git不会忽略任何.vs文件夹(VS2015)

[英]Git is not ignoring neither checking out .vs folder (VS2015)

In my .gitignore file, there's a line to ignore the Visual Studio 2015 folder (".vs/"), but it's not being ignored. 在我的.gitignore文件中,有一行可以忽略Visual Studio 2015文件夹(“ .vs /”),但不会被忽略。

And, besides, I can't use the checkout command. 而且,此外,我不能使用checkout命令。 That's what was returned: 那就是返回的内容:

Untracked files:
  (use "git add <file>..." to include in what will be committed)

        .vs/

PS C:\path\to\project> git checkout -- .vs/
error: pathspec '.vs/' did not match any file(s) known to git.

What's wrong? 怎么了?

Try below - 尝试以下-

git rm -r .vs

then open .gitignore and add end of file 然后打开.gitignore并添加文件结尾

.vs/

This should work 这应该工作

Make sure you do have a .gitignore file at the same level (or above) of the .vs folder, and that it does contain .vs/ (no extra space at the end of that line). 请确保你有一个.gitignore在同一级别(或以上)的文件.vs文件夹,而且它确实包含.vs/ (在该行的末尾没有多余的空间)。

Try that same rule in a subfolder/.vs (where you would create a lest a file), to see if it does work there. 尝试在subfolder/.vs (您将在其中创建一个文件)中使用相同的规则,以查看该文件是否在此处起作用。

I don't know about the checkout problem, but I encountered the ".vs" problem today. 我不知道结帐问题,但今天遇到了“ .vs”问题。 It's because my .gitignore file was created in VS, therefore the file was encoded with UTF8 with BOM, and ".vs" was written on the first line. 这是因为我的.gitignore文件是在VS中创建的,因此该文件使用带有 BOM的UTF8进行了编码,并且在第一行中写入了“ .vs”。 Since git cannot properly read the first line, ".vs" wouldn't work. 由于git无法正确读取第一行,因此“ .vs”不起作用。 Typical MS style... Just remove the BOM. 典型的MS样式...只需删除BOM。

Your Problem 你的问题

Your path should be .vs\\ 您的路径应为.vs\\

The Problem 问题

The syntax for .tfignore is not well understood. .tfignore的语法没有被很好地理解。

The Other Problem 另一个问题

Visual Studio Websites (NOT projects), do not have the " Exclude From Project " option on the right-click context menu. Visual Studio网站(非项目)在右键单击上下文菜单上没有“ 从项目中排除 ”选项。 This is where .tfignore comes very handy. 这是.tfignore派上用场的地方。


.tfignore DOES WORK for VS2013 and VS2015 .tfignore对VS2013和VS2015有用


The Rules 规则

MSDN link MSDN链接

  1. # begins a comment line (omit single quotes) #开始注释行(省略单引号)
  2. The * and ? *和? wildcards are supported. 支持通配符。
  3. A filespec is recursive unless prefixed by the \\ character. 除非以\\字符为前缀,否则filespec是递归的。
  4. ! negates a filespec (files that match the pattern are not ignored) 对filespec求反(不忽略与模式匹配的文件)

Examples 例子

Given project structure: myproject\\subfoler\\file.ext 给定的项目结构: myproject \\ subfoler \\ file.ext

# Ignores all files in the folder and all sub-folders recursively #递归地忽略文件夹中的所有文件和所有子文件夹
 myproject\\*.* 
# Ignores ONLY files in the folder but NOT the sub-folders. #忽略文件夹中的文件不是子文件夹。 Notice the beginning backslash \\ 注意开始的反斜杠\\
 \\myproject\\*.* 
# Ignores all files ONLY in the sub-folder 忽略子文件夹中的所有文件
 \\myproject\\subfoler\\*.* 
# Ignores all files in this folder and all sub-folders. #忽略此文件夹和所有子文件夹中的所有文件。 Does not ignore any file with extension .ext in the subfolder 不会忽略子文件夹中任何扩展名为.ext的文件
 myproject\\*.* !myproject\\subfolder\\*.ext 

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

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