git add multiple files at once

user1051003 picture user1051003 · Dec 7, 2011 · Viewed 83.4k times · Source

I had this project with a lot .c files in source directory,then I make the project, there is .o files inside of the project, I also want to push these files to repository,so instead of add each .o which is possible but...,how to add .o files easily?

Answer

elbowlobstercowstand picture elbowlobstercowstand · Apr 22, 2015

How to add multiple files with different extensions to git all at one time...

You can add to git by explicitly listing each file with spaces as delimiters.

$ git add file-name-1.php file-name-2.js file-name-3.html …

The accepted answer is perfect for the OP’s specific case. But I got here—via Google—needing to add multiple files with different extensions. Posting here in case you miss this similar answer to a similar question.

Don't forget about interactive staging

Git interactive staging can also work wonders. To enter interactive staging (aka: adding, removing files):

 $ git add -i