1

I have recently created a new repo and copied all my Java code written with eclipse in that repo. I have also a .gitignore file to ignore all the eclipse related .class bin files but when i try to push my changes to repo it starts to upload all the stuff and thats huge 140 MB. I wonder why ??

Below, i will tell you the steps that i have been following

1: In my Java Algorithm git folder i copied my Java project directly from the Eclipse workspace

2: Created a .gitignore in the same folder

3: Now the git status shows my java project as untracked.

4: I add it commit it and push it. But here it totally ignores .gitignore..

EDIT: Here is my .gitignore

C:\Users\Salman\Documents\GitHub\Java-Algorithm [master +1 ~0 -0 !]> cat .gitignore

bin

.settings
.classpath
.project

*.class
*.jar
*.war
*.ear

and the files in my Java Eclipe Project i.e DesignAndAnalysisOfAlgorithms are

C:\Users\Salman\Documents\GitHub\Java-Algorithm\DesignAndAnalysisOfAlgorithm [master +1 ~0 -0 !]> ls


Directory: C:\Users\Salman\Documents\GitHub\Java-Algorithm\DesignAndAnalysi
sOfAlgorithm


Mode                LastWriteTime     Length Name
----                -------------     ------ ----
d----         8/12/2012   2:04 PM            .settings
d----         8/12/2012   2:04 PM            bin
d----         8/12/2012   2:04 PM            src
-a---         8/12/2012   4:52 AM        301 .classpath
-a---         8/12/2012   4:52 AM        404 .project

Thanks

mu_sa
  • 2,685
  • 10
  • 39
  • 58
  • Please post your .gitignore and an example path you are trying to exclude. – JRG Aug 12 '12 at 11:15
  • sure, will modify the question now – mu_sa Aug 12 '12 at 11:16
  • Checkout the answers on this question: http://stackoverflow.com/questions/2900816/gitignore-not-working-for-me?rq=1 Sounds like you may have the issue last answer described (at the bottom) – dineth Aug 12 '12 at 11:30
  • *“I add it”* – How did you do that? There are different ways to add things, some of them not respecting what is specified in the gitignore. – poke Aug 12 '12 at 20:07

1 Answers1

4

Two ideas:

First, as you seem to work with Eclipse, make sure that you run git in the same directory as .gitignore

Second, if you already tracked a *.class file before you decided to ignore all *.class files by using .gitignore it will still be tracked. You can un-track it by:

git rm --cached filename

See also: https://help.github.com/articles/ignoring-files

Marcel Hebing
  • 3,072
  • 1
  • 19
  • 22
  • Same problem here, I've already tracked `*.class` files and `.gitignore` is not working. Used `git rm --cached *.class` after modifying `.gitignore` and committing all changes and it worked. – Salvatorelab Apr 04 '13 at 09:02