3

I am trying to setup gitignore to exclude all subdirectories except for 2. I have included ~!~ for the two i want to include but Sourcetree does not pick it up.

Here is my relevant gitignore

# .gitignore
node_modules/
wp-content/plugins/
wp-content/upgrade/
!wp-content/plugins/export-tool
!wp-content/plugins/darwin_checkout_tracking

The two files were set to be included just not. Before they were excluded.

Kalamarico
  • 5,466
  • 22
  • 53
  • 70
codeNinja
  • 1,442
  • 3
  • 25
  • 61
  • Possible duplicate of [.gitignore exclude folder but include specific subfolder](https://stackoverflow.com/questions/5533050/gitignore-exclude-folder-but-include-specific-subfolder) – phd Sep 24 '17 at 20:28

2 Answers2

2

The /* is important, you must do:

# .gitignore
node_modules/
wp-content/plugins/*
wp-content/upgrade/*
!wp-content/plugins/export-tool
!wp-content/plugins/darwin_checkout_tracking

And it works

Kalamarico
  • 5,466
  • 22
  • 53
  • 70
0

you can try this :

# .gitignore
!wp-content
node_modules/
wp-content/plugins/*
wp-content/upgrade/*
!wp-content/plugins/export-tool
!wp-content/plugins/darwin_checkout_tracking
Slim KTARI
  • 294
  • 2
  • 9