命令'git add。'我创建gitignore文件时添加我不需要的文件

时间:2013-11-07 09:51:55

标签: git gitignore

这是我的.gitignore文件内容:

# Executables

[0-1][1-5]/my*

我的git目录是:

    .
    |-- 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

我想在dir [01] [02]下排除文件...以我的*开头,但是当我使用命令时 git add .,文件my *出现在gitrepostory中。

有人可以告诉我原因吗?

1 个答案:

答案 0 :(得分:0)

嗯,我做了一个实验,这样,你的方法没有问题。所以我认为原因可能是git的其他配置让.gitignore文件禁用。在这里,我列出了我的测试过程 ➜perlexamplesgit:(test3)✗mkdir02 ➜perlexamplesgit:(test3)✗vim.gitignore 将[0-1] [1-5]添加到gitignore文件 ➜02git:(test3)✗vimmy.txt ➜02git:(test3)✗git st

On branch test3

未跟踪文件:

(使用“git add ...”包含将要提交的内容)

../ 20131026_craw_test.pl

1 ssdf

../ hash_test.pl

../ other_mech.pl

../ rsp.txt

../ words.pl

存储库中没有my.txt文件

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

➜perlexamplesgit:(test3)✗git st

On branch test3

未跟踪文件:

(使用“git add ...”包含将要提交的内容)

02 /

20131026_craw_test.pl

hash_test.pl

other_mech.pl

rsp.txt

words.pl

没有添加到提交但未跟踪的文件存在(使用“git add”跟踪)

现在02 /在存储库中。