简体   繁体   中英

command 'git add .' add the file I needn't when i created the gitignore file

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

On branch test3

Untracked files:

(use "git add ..." to include in what will be committed)

#

../20131026_craw_test.pl

1 ssdf

../hash_test.pl

../other_mech.pl

../rsp.txt

../words.pl

no my.txt file in the repository

➜ 02 git:(test3) ✗ vim a.txtwq

➜ perlexamples git:(test3) ✗ git st

On branch test3

Untracked files:

(use "git add ..." to include in what will be committed)

#

02/

20131026_craw_test.pl

hash_test.pl

other_mech.pl

rsp.txt

words.pl

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.

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