Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/23.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,对于dr1,我有这样的目录结构: . ├── dr2 │ ├── hi.txt │ └── inputs │ ├── anotherbigfile.big │ └── bigfile.big ├── dr3 │ ├── bye.txt │ ├── inputs │ │ ├── anotherbigfile.bigfile │ │ └── bigfile.bigfile │ └── small.txt └── dr4 └── by

对于
dr1
,我有这样的目录结构:

.
├── dr2
│   ├── hi.txt
│   └── inputs
│       ├── anotherbigfile.big
│       └── bigfile.big
├── dr3
│   ├── bye.txt
│   ├── inputs
│   │   ├── anotherbigfile.bigfile
│   │   └── bigfile.bigfile
│   └── small.txt
└── dr4
    └── bye.txt
My
dr1
是一份git回购协议,包含
.gitignore
,内容如下:

输入/

我想在
dr1
中暂存所有内容,我是指所有子目录和所有文件,我只是不想在每个子目录
dr2
dr3
dr4
中暂存、提交和推送
输入
目录。这些文件包含大文件,我在github中不需要它们

我从
dr1
中添加了
git。但是我遇到了一个问题,因为只有子目录被暂存,而没有内容,所以在我的repo中,我只有空目录,只有
dr4
子目录工作,因为那里没有包含
输入的文件夹。
这里怎么了?我以为
git
只会忽略子目录
input
,但目录的其余部分将被暂存

您可以使用

您可以将下一行添加到
.gitignore
文件中:

dr2/inputs/
dr3/inputs/
如果您不想具体说明,并且非常确定将来不需要提交任何
输入
子文件夹,则可以使用:

**/inputs/

在你的
.gitignore

中,这是否回答了你的问题?我不能在我的机器上复制。您是否发布了
.gitignore
的完整内容?运行
git check ignore-v**/*
检查是否由于某些忽略规则而跳过了其他文件。“仅暂存子目录”没有多大意义:git不跟踪空目录。这些目录是子模块吗?或者文件系统上的符号链接。为什么双星号
***
而不是单个星号?@alex
***
与任何字符零次或多次匹配,包括
/
。因此,它将忽略任何子目录中的
inputs
文件夹。如果只想忽略上层子文件夹的子文件夹的
输入,可以将其替换为
*
。git status
命令的输出是什么?您的
.gitignore
是什么样子的呢?输出没有要提交的内容。我的
.gitignore
是dr2/inputs/dr3/inputs/I使用
git add.
来自
dr1
但在
gitignore
修改后它仍然没有跟踪