Is it possible to use git checkout -- on multiple files in order to discard the changes?
If so how would I specify multiple files?
List the two (or more) files in a file.
With Git 2.25 (Q1 2020), a few more commands learned the "--pathspec-from-file" command line option, which I previously mentioned for git commit.
That means you can use the old confusing git checkout command, or the new command (Git 2.23+) git restore with a list of files (to checkout/restore), instead of reaptinng multiple time the same command on different files.
See commit a9aecc7, commit cfd9376, commit 8ea1189, commit 6fdc9ad, commit 1d022bb, commit bebb5d6, commit 21bb308 (03 Dec 2019) by Alexandr Miloslavskiy (SyntevoAlex).
(Merged by Junio C Hamano -- gitster -- in commit 135365d, 25 Dec 2019)
checkout, restore: support the
--pathspec-from-fileoptionSigned-off-by: Alexandr Miloslavskiy
Decisions taken for simplicity:
- For now,
--pathspec-from-fileis declared incompatible with--patch, even whenis notstdin. Such use case it not really expected.- It is not allowed to pass pathspec in both args and file.
you must specify path(s) to restoreblock was moved down to be able to test forpathspec.nrinstead, because testing forargcis no longer correct.git switch does not support the new options because it doesn't expect
arguments.
With Git 2.26 (Q1 2020) adds more tests.
See commit f94f7bd (30 Dec 2019) by Alexandr Miloslavskiy (SyntevoAlex).
(Merged by Junio C Hamano -- gitster -- in commit 96aef8f, 30 Jan 2020)
t: add tests for error conditions with --pathspec-from-file
Suggested-By: Phillip Wood Signed-off-by: Alexandr Miloslavskiy Signed-off-by: Junio C Hamano