If your Git version is new enough,
git add -- . ':!<path>'
.
means all under the current directory, and ':!<path>'
means to exclude the path. So it means to add all except path
.
The term for . ':!<path>'
is pathspec. However, the doc is a bit obscure and lack of abundant examples. I find this post very helpful to understand pathspec
.