ankitd
ankitd

Reputation: 2007

Git reset all files with particular extension

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

Upvotes: 15

Views: 11405

Answers (2)

JBallin
JBallin

Reputation: 9787

git reset master -- "*.scss.d.ts"

Upvotes: 15

Romain Valeri
Romain Valeri

Reputation: 21908

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'

Upvotes: 20

Related Questions