Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

difference between * and /* in gitignore

Tags:

git

gitignore

I find /* and * has different means when I compare with the setting:

*

!/init.el
!/README.md
!.gitignore
!/lib/

VS

/*

!/init.el
!/README.md
!.gitignore
!/lib/

The former not track /lib/ but the latter track it.

How to undertand * and /*?

UPDATE
I think this question is not exactly same as another one. Because he is focus on dir/** and dir/* but this one is focus on /* and *.

like image 750
LoranceChen Avatar asked Mar 14 '18 14:03

LoranceChen


Video Answer


1 Answers

The first version ignores all files except those listed explicitly. lib is ignored because it contains no trackable files. Git does not track folders, so directories that appear empty seem to get ignored.

The second version ignores all root level files and directories except those listed explicitly. It does not ignore anything that is trackable and not in the root directory. lib is listed explicitly, so it is not ignored. Any files it contains are not at the root level, so they aren't ignored either.

like image 124
Mad Physicist Avatar answered Sep 30 '22 16:09

Mad Physicist