Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to just commit one file type extension from a folder?

I have a folder with a lot of stuff and I would like just to commit ".c" extension files. Is there a command to do this or do I need to add each file name manually?

like image 736
Victor R. Oliveira Avatar asked Oct 31 '14 20:10

Victor R. Oliveira


People also ask

How do I commit a single file in Git?

Enter git add --all at the command line prompt in your local project directory to add the files or changes to the repository. Enter git status to see the changes to be committed. Enter git commit -m '<commit_message>' at the command line to commit new files/changes to the local repository.


1 Answers

For me, just git add *.c didn't work. I encountered fatal error like this:

git add *.php The following paths are ignored by one of your .gitignore files: wp-config.php Use -f if you really want to add them. fatal: no files added 

So, in this variant git tried to add ignored files.

But such variant:

git add \*.php 

worked flawlessly. By the way, you can do git diff the same way:

git diff -- \*.php 
like image 67
Sergey Zaharchenko Avatar answered Nov 10 '22 07:11

Sergey Zaharchenko