1

I have Spring module project on Bitbucket with 2 Spring Boot apps in it. In the root module I have the .gitignore file and in every app I have .gitignore file with this content :

config.properties
.classpath
.project
.settings/
.idea/
target/
*.iml

I tried pulling project again but no changes. Config.properties do get ignored but target folder isn't. Every time I make some change, I get target folder file in my git changes list.

target folder files in git

Archmede
  • 1,302
  • 1
  • 16
  • 32
user3364181
  • 431
  • 3
  • 12
  • 31

4 Answers4

7

There are a couple possibilities that come to mind.

  1. Ensure that you haven't yet committed the target/ folder. This would prevent the gitignore from doing its job and ignoring the added folder.

  2. The other thought is you have a multi-module project. Ensure you are calling the correct target/ folder to ignore: How to .gitignore files recursively

bkwdesign
  • 1,613
  • 1
  • 24
  • 47
4

The new patterns in the gitignore don´t work for existing directories. Make sure to remove the existing entries in the git for the target folders:

git rm -r --cached etplans-web/target
kevin Lema
  • 110
  • 1
  • 7
  • I executed this command and after that git ls-files this one, and target folder wasn't on list. Now when i check status with git status, i have a ton of deleted files from target folder. Should i commit that or ? – user3364181 Dec 11 '17 at 17:51
  • @user3364181 Try to make a commit and check if the gitignores respects your pattern (target/) now – kevin Lema Dec 12 '17 at 07:57
0

Make sure that your "target/" folder path is correct. Look for examples here

Comteng
  • 19
  • 5
0

i think its because you've accidentally added a file in target directory and so git doesn't ignore it. hope this would help