git - 添加 *,但 sibling 被忽略

标签 git gitignore

我在目录中进行了一系列更新并想添加它们,但它们位于我的 .gitignore 中的目录旁边。 git add 不应该只是忽略而不是提示吗?

我怎样才能添加所有内容并跳过被忽略的内容?

$ git add assets/*
The following paths are ignored by one of your .gitignore files:
assets/avatars
Use -f if you really want to add them.
fatal: no files added

最佳答案

根据 documentation--ignore-errors 标志只会让命令按照您的意愿工作。

If some files could not be added because of errors indexing them, do not abort the operation, but continue adding the others. The command shall still exit with non-zero status. The configuration variable add.ignoreErrors can be set to true to make this the default behaviour.

更新:

这在这种情况下不起作用,我猜是因为 assets/* 参数被 shell 扩展了,所以 git add 接收到的实际参数是文件和目录的扩展列表,因此失败是明确的。

我已经尝试过这个命令并取得了很好的效果:

$ git add assets

即使没有选项 --ignore-errors 它也能工作,因为它不会尝试在 assets 下添加被忽略的目录。

关于git - 添加 *,但 sibling 被忽略,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31613195/

相关文章:

git - 如何忽略带有 .gitignore 文件的文件?

Git:我在 bitbucket 网页中挑选的提交在哪里?

Eclipse EGIT - 所有提交, pull , merge ,标记为 merge ,仍在推送我得到 "rejected - non-fast forward",我错过了什么?

git push 到指定分支

git stash 恢复被忽略的文件

git - .gitignore 如何忽略目录中的一级文件而不是子文件?

git - 将光标移动到之前所在行的 vim 命令是什么?

git - 为什么 github 的提交不显示 'verified'(签名提交)?

git - 如果我在忽略中使用通配符作为文件夹路径,如何在 .gitignore 中执行异常?

gitignore > 一些被忽略的文件仍然添加到存储库中