When specifying a directory in .gitignore, does the presence or absence of a trailing /(slash) make sense?

Asked 1 years ago, Updated 1 years ago, 361 views

Here is an excerpt from .gitignore when you created the Next.js project.

#next.js has / at the end of the directory, while #production has / at the end.
What is the difference?Also, is the presence or absence of / at the end of this not limited to .gitignore, but is it a general description?

example:

#next.js
/.next/
/out/

# production
/build

git

2022-12-12 06:29

1 Answers

When specifying a directory, the ending / has a special meaning.
(Not only .gitignore, but also rsync commands are often treated the same way.)

reference:
How to write .gitignore.Exclude Files/Directories

If you want to exclude all files under the directory from being tracked, place a "/(slash)" at the end.

The ending // 」 signifies なexclusion of directories and their subordinates その with special meaning, and even if a file with the same name exists, it will not be matched.

If there is no slash, it is normal pattern matching and if a match is found in the path, it is excluded.


2022-12-12 09:13

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.