我在目录中进行了一系列更新并想添加它们,但它们位于我的 .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/