0

I've a project structure as following:

project(':x1').projectDir = new File('./modules/...')
project(':x2').projectDir = new File('./modules/...')

project(':a1').projectDir = new File('./features/.../...')
project(':a2').projectDir = new File('./features/./.')

So I want to make sure all generated/build files are ignored under features folder and module folder.

Current .gitignore file:

# ignore vim swap files
*.swp
# ignore test files
TEST-*.xml
# ignore eclipse .settings files
.settings/
.project
.classpath

# ignore idea files
*.iml
.idea/

# ignore mac stuff Mac
.DS_Store

# ignore eclipse/idea/ant/maven/gradle output
bin/
local.properties
signing.properties
build/
gen/
classes
.gradle
out/
target
captures/

# ignore modules and features folders
!file:*build*/
modules/**/build/
**/build/
!file:*build*/&&!lib:*..*
MaaAn13
  • 264
  • 5
  • 24
  • 54
  • Your git ignore file looks good at a first hance. Do you have problems with build folders not covered by it or other problems with? Because otherwise your question would already be answered in your question... – Robert Apr 09 '23 at 22:50
  • I'm not sure why when I build the app and run it, my git gets overwhelmed with 200 files changed, whereas based on my gitignore, I'd expect that these files are ignored. All of them come from build/generated. – MaaAn13 Apr 09 '23 at 23:02
  • you have one single monorepo, correct ? no submodules involved ? (if you have submodules: you would have to ignore files submodule by submodule) – LeGEC Apr 10 '23 at 07:06
  • Otheriwse: if these files were already tracked, you need to use `git rm` or `git rm --cached` to remove them from tracking: https://stackoverflow.com/questions/1274057 – LeGEC Apr 10 '23 at 07:09
  • FWIW: `!file:...` is not a pattern known to gitignore, AFAIU it would apply to files whose name start with `"file:"...` ; `build/` (with no leading `/`, only a trailing one) will already ignore any sub directory named `build/`, so the `**/build/` patterns at the end are redundant. Check [`git help gitignore`](https://git-scm.com/docs/gitignore) – LeGEC Apr 10 '23 at 07:12
  • @LeGEC I feel little bit awkward right now. Turns out I did commit already build/generated folders and thus .gitignore changes did not help. After I commit new commit with stop tracking these folders (in GitKraken: Right click -> stop tracking and ignore), then .gitignore rules were working as expected. Thanks. – MaaAn13 Apr 10 '23 at 10:33
  • sure, no worries :) many people trip on that one – LeGEC Apr 10 '23 at 10:58

0 Answers0