Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
递归忽略git中的文件夹_Git - Fatal编程技术网

递归忽略git中的文件夹

递归忽略git中的文件夹,git,Git,如何忽略名为build,bin的所有文件夹。我试过这么做 **/bin/ **/build/ 但它不起作用。在git状态下,我看到了 # new file: BS/server/build/obj/sender.o # new file: BS/server/build/obj/sendistate.o # new file: BS/server/build/obj/serializedata.o # new file: BS/client/bin/gc.sam

如何忽略名为
build
bin
的所有文件夹。我试过这么做

**/bin/
**/build/
但它不起作用。在git状态下,我看到了

#   new file:   BS/server/build/obj/sender.o
#   new file:   BS/server/build/obj/sendistate.o
#   new file:   BS/server/build/obj/serializedata.o
#   new file:   BS/client/bin/gc.sample.xml
#   new file:   BS/client/bin/mkab.qss
#   new file:   BS/client/bin/mkaberr.qss
#   new file:   BS/client/build/debug/application.qss
#   new file:   BS/client/build/debug/config.xml

如果要忽略目录,则应为“directoryname/”。 比如说

bin/
build/
  • 空的测试示例
    .gitignore

  • 带有填充的测试示例
    .gitignore


*/build/*
应该比Rémi Benoit更好,即使它不起作用。我可以做/*/buid/,但我需要做这个递归。
➜  /tmp  mkdir -p test/ab/{bin,build}  
➜  /tmp  touch test/ab/{bin,build}/file.txt
➜  /tmp  tree -a
➜  /tmp  tree -a test 
test
└── ab
    ├── bin
    │   └── file.txt
    └── build
        └── file.txt

3 directories, 2 files
➜  /tmp  cd test
➜  test  git init
Initialized empty Git repository in /tmp/test/.git/
➜  test git:(master) ✗ git add -An
add 'ab/bin/file.txt'
add 'ab/build/file.txt'
➜  ~  cd /tmp 
➜  /tmp  mkdir -p test/ab/{bin/,build}
➜  /tmp  touch test/ab/{bin,build}/file.txt
➜  /tmp  cat > test/.gitignore
bin
build
➜  /tmp  tree -a test 
test
├── ab
│   ├── bin
│   │   └── file.txt
│   └── build
│       └── file.txt
└── .gitignore

3 directories, 3 files
➜  /tmp  cd test 
➜  test  git init
Initialized empty Git repository in /tmp/test/.git/
➜  test git:(master) ✗ git add -An
add '.gitignore'