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

孤人 提交于 2020-01-13 19:38:29

问题


In my .gitignore file, there's a line to ignore the Visual Studio 2015 folder (".vs/"), but it's not being ignored.

And, besides, I can't use the checkout command. 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?


回答1:


Try below -

git rm -r .vs

then open .gitignore and add end of file

.vs/

This should work




回答2:


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).

Try that same rule in a subfolder/.vs (where you would create a lest a file), to see if it does work there.




回答3:


I don't know about the checkout problem, but I encountered the ".vs" problem today. 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. Since git cannot properly read the first line, ".vs" wouldn't work. Typical MS style... Just remove the BOM.




回答4:


Your Problem

Your path should be .vs\

The Problem

The syntax for .tfignore is not well understood.

The Other Problem

Visual Studio Websites (NOT projects), do not have the "Exclude From Project" option on the right-click context menu. This is where .tfignore comes very handy.


.tfignore DOES WORK for VS2013 and VS2015


The Rules

MSDN link

  1. # begins a comment line (omit single quotes)
  2. The * and ? wildcards are supported.
  3. A filespec is recursive unless prefixed by the \ character.
  4. ! negates a filespec (files that match the pattern are not ignored)

Examples

Given project structure: 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
myproject\*.*
!myproject\subfolder\*.ext


来源:https://stackoverflow.com/questions/31931751/git-is-not-ignoring-neither-checking-out-vs-folder-vs2015

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!