Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GIT stage and commit only files with a certain file ending

I have tons of modified files, and a good 2/3s of the files are images that I don't care much about, but I still want to commit them. For the rest I need to really look hard at the changes. To minimize the files I need to look at I want to only stage .png and .jpg and .gif files and commit them (cutting down the background noise in order to look at the beef).

Having said that...

How would you stage and commit only files with these file endings without adding each file separately?

Edit:

Files are modified

Directory structure is not flat

I am overwriting a WP Theme that I have highly customized and there is a security update I need to apply

like image 306
mahatmanich Avatar asked Sep 04 '25 16:09

mahatmanich


1 Answers

Simply

git add \*.jpg \*.png

This will add all tracked and modified files in your repository which match the wildcard pattern

If your image files are the only things under a specific directory

git add <directory>

will add everything under that directory

like image 67
kdopen Avatar answered Sep 07 '25 06:09

kdopen