I have a .gitignore
file that looks like this:
*
!/src
!/resources
!/.gitignore
!/package.json
!/tsconfig.json
!/README.md
I added a file to a subdirectory in the src
folder src/config/mongo.ts
. However, when I try to add the file it doesn't get added:
git add -A
I have tried modifying the second line to each of the following:
!/src/
!/src/*
!/src/**/*
However it still doesn't add the file.
I have also tried adding the file directly:
git add src/config/mongo.ts
But I get the following message:
The following paths are ignored by one of your .gitignore files: src/config/mongo.ts
git status
only shows that the .gitignore
file has been changed. Not sure what to do to get this working.
I would like to:
*
src
directory (and its subdirectories) resources
directory (and its subdirectories) This one is a tricky one, took me forever to figure out when I originally ran into it.
You just need to soften the initial exclusion slightly:
/* # instead of just *
src folder and its subdirectories are being ignored by git
if you want to add specific file. try
git add --force <file-path>
or try these lines in gitignore
/*
!/src
/src/*
!/resources
!/.gitignore
!/package.json
!/tsconfig.json
!/README.md
!/src/config
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.