Mike McCoy
Mike McCoy

Reputation: 797

In Git, removing DLL and PDB files that have accidently been committed

I have a git repo that I need to get working without conflicts. It is .net/c# mvc repo. The problem is dll and pdb files. These files have been accidentally committed to the repo so when I do my initial git pull, I get all these files committed by another developer.

I have setup the .gitignore like so:

bin/
obj/
App_data/

From other posts I believe that is all I should need to do, however, If I build my project and run git status it shows numerous dll and pdb files that are going to be committed.

Is this because those files existed in the repo when I cloned it? If so, what is the best way to go about removing those files?

Upvotes: 12

Views: 9700

Answers (3)

Darren G
Darren G

Reputation: 233

Your .gitignore File has a mistake. It should be like this:

bin
obj
App_data

Upvotes: 0

Gregor
Gregor

Reputation: 388

This is very common question and the usual answer is that you cannot clean up past commits, but there are special tools for this . git filter and easier the BFG repo cleaner: http://rtyley.github.io/bfg-repo-cleaner/#usage

Upvotes: 1

VonC
VonC

Reputation: 1326776

You need to remove those file first (git rm), before seeing your .gitignore directoves applied to your git repo.

You can remove those files only from the index if you want to keep them on the working tree.

git rm -r --cached a.dll

(See ".gitignore file not ignoring")

But for generated files, it shouldn't matter if they are removed: you will re-create them at the next compilation, but ignore them because they aren't part of the index anymore.

Upvotes: 12

Related Questions