bkoodaa
bkoodaa

Reputation: 5351

Gitignore only works on some folders

I have the following 2 lines in .gitignore

Valhalla/.idea/
Valhalla/target/

When I push to GitHub, it skips the .idea folder, but it still uploads the target folder. How can I make it also skip the target folder?

Upvotes: 0

Views: 29

Answers (1)

jhilden
jhilden

Reputation: 12449

.gitignore only works for folders that are not already tracked. So if you had previously committed the folder Valhalla/target then it's going to keep tracking it. To resolve that do the following:

  1. comment out the line Valhalla/target in your .gitignore
  2. commit
  3. delete the folder Valhalla/target in your project
  4. commit
  5. add back the line to your .gitignore
  6. commit

That folder show now be untracked and if you add it back then it should be ignored and not re-added.

Upvotes: 2

Related Questions