2

Always when I run git status some files are listed as untracked, that is how it should be. But I would like to not have them listed there everytime I run git status. As what I have understood, I should add those files to an .gitignore-file.

In my project I have a file .classpath and a directory .gradle/* that I want to ingore.

My .gitignore file looks like this:

.classpath
.gradle/*

but these files are still listed as "untracked" when I run git status. Is there anything wrong with my .gitignore file or how should I fix this?


Here is my git status output:

C:\myproject>git status
# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       modified:   src/Test.java
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       .classpath
#       .gitignore
#       .gradle/
no changes added to commit (use "git add" and/or "git commit -a")
Jonas
  • 121,568
  • 97
  • 310
  • 388
  • uhm weird, it should already ignore them, try to add a slash in front of each entry... – Andreas Linden Nov 03 '12 at 11:45
  • The gitignore you posted works perfectly fine; i just tried it. Please include your `git status` output in the question. It sounds a bit like you already added the file. – ThiefMaster Nov 03 '12 at 11:46
  • Been answered before: http://stackoverflow.com/questions/11451535/gitignore-not-working – brk3 Nov 03 '12 at 11:47
  • @ThiefMaster ok, I added `git status` output – Jonas Nov 03 '12 at 11:53
  • @brk3: it seem to be the same problem, but that solution doesn't work for me. So it's unsolved, so far. – Jonas Nov 03 '12 at 11:55
  • have you looked at http://stackoverflow.com/questions/343646/ignoring-directories-in-git-repos-on-windows? – ThiefMaster Nov 03 '12 at 11:56
  • @ThiefMaster that question doesn't help me. I created the file this way: http://superuser.com/a/498909/27037 – Jonas Nov 03 '12 at 12:01

2 Answers2

3

I found out that the paths in my .gitignore file had a space in the end of each row. When I removed the space char from each line in .gitignore it worked fine. This is how I created my .gitignore file:

https://superuser.com/a/498909/27037

echo .classpath> .gitignore
echo .gradle/*>> .gitignore

and before I used this commands (does not work):

echo .classpath > .gitignore
echo .gradle/* >> .gitignore
Community
  • 1
  • 1
Jonas
  • 121,568
  • 97
  • 310
  • 388
1

This works for me:

.classpath
.gradle/

Make sure you git add . to stage the .gitignore file.

Don Branson
  • 13,631
  • 10
  • 59
  • 101