0

I have a project set up in /home/xxx/project. My .gitignore is in /home/xxx/project/.gitignore, and I'm trying to add the file /home/xxx/project/.idea/workspace.xml to gitignore. Here's my .gitignore file:

target/
uploads/
*.class
.idea/workspace.xml

All the other lines work, but the last one has no effect, and I keep seeing changes from workspace.xml when I try to commit.

What am I doing wrong?

Ali
  • 261,656
  • 265
  • 575
  • 769
  • When you say "keep seeing changes" it sounds like the file is already tracked. Is it? – CB Bailey Mar 15 '14 at 12:14
  • is this file already being tracked by git? (i.e. you committed it?) – thescientist Mar 15 '14 at 12:14
  • Maybe you have already checked in the file. Then the .gitignore results in no difference. Delete the file. Commit the deletion. And then add it back in. Now the .gitignore should do it's job. – DAG Mar 15 '14 at 12:16
  • @ChristianGärtner Yes, the file is currently being tracked already. – Ali Mar 15 '14 at 12:16
  • possible duplicate of [.gitignore file not ignoring](http://stackoverflow.com/questions/1139762/gitignore-file-not-ignoring) – Joe May 25 '14 at 02:40

1 Answers1

3

If you have already set this file for tracking in Git, it's too late to add it to .gitignore and see the behavior your expecting.

What I would do is:

  1. Back this file up somewhere
  2. Delete it from Git
  3. Add it to .gitignore
  4. Move the file back into your workspace
  5. git status (should not show the file)
thescientist
  • 2,906
  • 1
  • 20
  • 15
  • that's strange, because sometimes in the past, even when i had a file committed, adding it to gitignore caused it to be ignored in future. Perhaps that was my IDE doing that. – Ali Mar 15 '14 at 12:18