-1

I know to use git checkout . and similar as explained here How do I discard unstaged changes in Git? but would like to know if it is possible to carry out "negative" discarding.

That is, discard unstaged changes to files that DO NOT match a set of extensions.

So instead of git checkout -- "*.ext". to discard changes to *.ext files, is it possible to do a sort of git checkout -- !(*.extA|*.extB|*.extC|*.extP)". when I have changes to *.extA to *.extZ files in place.

That is, to only be left with changes to the *.extA, *.extB, *.extC and *.extP files.

Is this possible at all and if so, how can I do this?

Dayo
  • 12,413
  • 5
  • 52
  • 67

1 Answers1

1

You can use path exclusions

git checkout -- . `:!*.extA' ':!*.extB' ':!*.extC' ':!*.extP' 
Mark Adelsberger
  • 42,148
  • 4
  • 35
  • 52