This is my .gitignore file content:
# Executables
[0-1][1-5]/my*
my git dir is:
.
|-- 01
| `-- more02.c
|-- 02
| |-- cp01.c
| |-- tmp
| |-- tmp.cop
| |-- utmplib.h
| `-- who01.c
|-- 03
| |-- ls01.c
| |-- ls02.c
| |-- myls
| |-- myls2
| `-- utility.h
|-- 04
| |-- mypwd
| `-- spwd.c
|-- 05
| |-- mystty
| `-- showtty.c
|-- 06
| |-- myerror
| |-- myplayagain
| |-- myplayagain3
| |-- myplayagain5
| |-- mysignal
| |-- play_again3.c
| |-- play_again.c
| `-- signaldemo1.c
|-- 07
| |-- hello2.c
| |-- hello3.c
| |-- myhello
| |-- myhello2
| |-- myticker1
| `-- ticker_demo1.c
|-- LICENSE
`-- README.md
I want exclude the file under dir [01] [02] ... start with my*, but when i use the command git add .
, the file my* appears in the gitrepostory.
someone can tell me the reason?
well, I have made an experiment that in this way, there is no problem with your method. So I think the reason may be other config of git to let the .gitignore file disable. Here I list my test process. ➜ perlexamples git:(test3) ✗ mkdir 02 ➜ perlexamples git:(test3) ✗ vim .gitignore add [0-1][1-5] to the gitignore file ➜ 02 git:(test3) ✗ vim my.txt ➜ 02 git:(test3) ✗ git st
#
1 ssdf
no my.txt file in the repository
➜ 02 git:(test3) ✗ vim a.txtwq
➜ perlexamples git:(test3) ✗ git st
#
nothing added to commit but untracked files present (use "git add" to track)
now 02/ is in the repository.
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.