Now git supports exclude certain paths and files by pathspec magic :(exclude) and its short form :!. So you can easily achieve it as the following command.
The -- option separates the add command from the list of files, so the files won't be mistaken as command-line options. In the case above, all files in the current directory (.), except excludedfile.
I've yet to find a documentation for the syntax of the exclusion of files, but I've been using the command and has been working for me (my Git version is 2.20).
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hey there,
Came across this post as I was searching for a solution to the same problem.
Saw this in StackOverflow:
answer re: Add all files to a commit except a single file?
Now
git
supportsexclude certain paths and files
by pathspec magic:(exclude)
and its short form:!
. So you can easily achieve it as the following command.Actually you can specify more:
…The
--
option separates theadd
command from the list of files, so the files won't be mistaken as command-line options. In the case above, all files in the current directory (.), exceptexcludedfile
.I've yet to find a documentation for the syntax of the exclusion of files, but I've been using the command and has been working for me (my Git version is 2.20).