Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git keeps adding bin and obj files even though there is an ignorefile

Tags:

git

gitignore

I have been working on a POC and now have been asked to upload it to our GitHub. I have done that, but today I notice the bin and obj folder being included.

So I opened up my .gitignore file to check I've added the Visual Studio profile. Which it was.. I could see [Bb]in/ and [Oo]bj/ are included.

So I tried to remove the folder from Git by typing:

git rm --cached -r [folder]/bin

After doing that I saw all the *dll being removed, I checked in Team Explorer and noted that the files were all removed.

Committed, and rebuilt to see that all the bin files returned...

it's not just one project in the solution. It seems to be all of them doing this. I have my .gitignore file in the root of my solution. As well as the .git folder. Screen shot of folder structure.

  • I tried copying the .gitignore file to the project folder. didn't work
  • I tried adding **/[Bb]in/ & **[Bb]in/ .. no change.

Any ideas on what I'm missing here?

My .gitignore is an exact copy of this here

I reverted my **/[Bb]in/ changes to see if I broke something.

like image 439
Anthony Avatar asked Jan 12 '17 01:01

Anthony


1 Answers

git ignore ignore the file that hadn't been tracked yet, so if a file was committed it will reappear again.

you can try:

git rm -r --cached . 
git add .

then

git commit -am "Remove ignored files"

as suggested here

or go for a more radical approach:

  • remove the files with rm
  • then reset the .git directory (remove it, then initialize it anew with git init)
  • create a new remote branch
  • push to the new branch
  • if all looks ok, then merge with the mean branch.
like image 88
yaitloutou Avatar answered Oct 12 '22 19:10

yaitloutou