Reputation: 129075
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")
Upvotes: 2
Views: 9353
Reputation: 129075
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
Upvotes: 3
Reputation: 13707
This works for me:
.classpath
.gradle/
Make sure you git add .
to stage the .gitignore file.
Upvotes: 1