Git reset all files with particular extension

Viewed 4639

I have changes in many types of file like .tsx .scss and .scss.d.ts, and have committed and pushed to my branch.

Is there any way I can reset only extension .scss.d.ts with master ?

Keep the changes in .tsx and .scss only reset .scss.d.ts with master.

Thanks

2 Answers

You could first output a list of the paths with

git ls-files master -- *.scss.d.ts

then that list can be send to the checkout command* to restore each of them to their state on master

git checkout master -- $(git ls-files master -- *.scss.d.ts)

* Note that since recent git versions, you also have git restore to the same effect

git restore --source=master '*.scss.d.ts'
Related