5

Is my .gitignore even working? I added packages folder to it and it still wants to commit all my packages on every commit.

What I'm doing at the moment is excluding package folder on every commit which is horrible. Am I missing something or it is bug within Visual Studio/Visual Studio Online Git System?

.gitignore

# NuGet Packages Directory
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
packages/

Image

enter image description here

Stan
  • 25,744
  • 53
  • 164
  • 242

3 Answers3

7

Your .gitignore should work, since "Included changes" in TFS 2013 doesn't mean staged changes, according to the FAQ:

If you are an experienced Git user, you might have noticed that Visual Studio handles changes differently than the command prompt.
You might have wondered if the Included Changes section contains your staged changes.
In fact, Visual Studio usually bypasses the Git stage for you. When you commit changes, Visual Studio simultaneously stages and commits them.
The one exception occurs when you add a file to your Git repository; Visual Studio does stage this kind of change.

So if you added a file, you might have to check git status in command line, and do a git rm --cached of that file.

But if not added any file, this is likely a current bug, as illustrated in "TFS/Git extensions seems to ignore .gitignore".

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
5

@VonC gave the answer you probably need.

If you had already committed the packages folder BEFORE adding/editing the .gitignore file then the packages will be 'tracked files'. Git will look to update them regardless of the .gitignore file. To exclude packages you'll need to remove them from your index and repository.

From the command prompt you use git rm -r --cached packages/ to remove the packages from your index while keeping them in your working folder. When you do a commit those files will also be removed from the repository.

Richard Banks
  • 12,456
  • 3
  • 46
  • 62
2

Sometime it happens with Visual Studio Git Plugin. All you need to fix it:

  1. In "Included Changes" section, right-click on "packages"
  2. Click on "Exclude All"
  3. In "Excluded Changes" section, right-click on "packages"
  4. Click "Undo"

These actions will help you to fix the problem