2

Why is my .gitignore file not ignoring specific files?

I need to ignore any file which starts with: .metadata/.

I have created a git file ( .gitignore ): Git ignore file

I have added the following text within the ignore file: .metadata/.*

However my file still seems to be showing the files in red:

± |master ↑8 U:44 ?:22 ✗| → git status
On branch master
Your branch is ahead of 'origin/master' by 8 commits.
  (use "git push" to publish your local commits)
Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   .metadata/.log
        modified:   .metadata/.mylyn/.tasks.xml.zip
        modified:   .metadata/.mylyn/tasks.xml.zip
        modified:   .metadata/.plugins/com.genuitec.eclipse.devstyle/recent.json
        modified:   .metadata/.plugins/com.genuitec.eclipse.monitor/myeclipse-usage.properties
Joe
  • 41,484
  • 20
  • 104
  • 125
DeltaBluee
  • 51
  • 1
  • 6
  • is metadata/ a folder name? – Grantly Jan 17 '18 at 12:51
  • 3
    is that a comma instead of a period ? – Esteban Garcia Jan 17 '18 at 12:52
  • Possible duplicate of [.gitignore is not working](https://stackoverflow.com/questions/11451535/gitignore-is-not-working) – phd Jan 17 '18 at 16:57
  • Possible duplicate of [How to make Git "forget" about a file that was tracked but is now in .gitignore?](https://stackoverflow.com/questions/1274057/how-to-make-git-forget-about-a-file-that-was-tracked-but-is-now-in-gitignore) – 1615903 Jan 17 '18 at 16:58

4 Answers4

3

According to your question the files are already committed. Git will continue reporting changes to ignored files that are committed. In you should remove the files you wish to ignore from your git repo by doing this: https://stackoverflow.com/a/1143800/556085

Specifically :git rm --cached mylogfile.log For a directory: git rm --cached -r mydirectory

KillerX
  • 1,436
  • 1
  • 15
  • 23
2

To ignore the metadata folder use **/metadata/*. (make sure you use version 1.8.2 of git or later)

Also, you mistyped .gitignore. (change the name of the file from ,gitignore to .gitignore)

You can also check out this generator -> gitignore.io

grrigore
  • 1,050
  • 1
  • 21
  • 39
0

To keep everything out of the ./metadata/ folder from being "seen" by git, add

/metadata/

to your .gitignore file.

Joe
  • 41,484
  • 20
  • 104
  • 125
0

You appear to have named your file ,gitignore instead of .gitignore.

nnnmmm
  • 7,964
  • 4
  • 22
  • 41