git没有添加文件夹和子文件夹

时间:2018-03-07 15:38:15

标签: git

我想将.idea文件夹添加到git(与大多数想要忽略它的开发者不同)。我已尝试过以下所有解决方案:

Recursively add the entire folder to a repository

但没有任何效果。我的gitignore只有这个:

**/build/ .gradle

我不知道为什么没有添加任何文件。

1 个答案:

答案 0 :(得分:1)

从这里提取:Force git to add dotfiles to repository

  

默认情况下不排除“点文件”,但可能会有一些   系统,存储库或工作树上的配置已设置   那样。如果它们出现在git ls-files --exclude-standard -oi中   他们被忽视了,并且"!。*"是'unignore'他们的正确方法。   但为了有效,这种模式必须在正确的位置。   忽略按以下顺序处理:

.gitignore of the immediately containing directory, then
.gitignore of the parent directory (each parent, up to the repository root), then
$GIT_DIR/info/exclude, then
the file reported by git config core.excludesfile (which could be set by
    $GIT_DIR/config,
    $HOME/.gitconfig, or
    the system config file (try GIT_EDITOR=echo git config --system --edit to get its pathname)).

或者通过路径名特别添加它们,例如,

git add */.*

find . -name '.[a-z]*' -exec git add '{}' ';'

如果没有这项工作,另一个(也许不是很漂亮)解决方案正在尝试创建一个符号链接,如:

ln -s ./idea ./.idea

希望它有所帮助!