简体   繁体   中英

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.

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?

Try below -

git rm -r .vs

then open .gitignore and add end of file

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

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

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.

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 

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