简体   繁体   中英

gitignore everything except a symlink

I have the following folder structure:

node_modules/
  my_symlink_to_lib
  folder_a/
  folder_b/
lib/
  (some files here)

I want to ignore everything inside node_modules except the symlink:

# Doesn't work
node_modules/*
!node_modules/my_symlink_to_lib

# Doesn't work
node_modules/*
!node_modules/my_symlink_to_lib
!node_modules/my_symlink_to_lib/*

I have tried several other stuff, node_modules/my_symlink_to_lib doesn't end up in untracked files.

Any ideas?

Make sure you don't have something like the following in .gitignore_global file:

# ignores the whole folder so negation won't work in local .gitignore
node_modules

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM