简体   繁体   中英

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

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'
git reset master -- "*.scss.d.ts"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM