Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

.net

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?

like image 491
Mike McCoy Avatar asked Aug 26 '12 20:08

Mike McCoy


2 Answers

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.

like image 58
VonC Avatar answered Sep 28 '22 05:09

VonC


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

like image 35
Gregor Avatar answered Sep 28 '22 05:09

Gregor