how to git commit a whole folder?

Here is a folder, which contains a lot of .java files.

How can I git commit this folder ?

If I do the following commands

git add foldername
git commit foldername -m "commit operation"

I will see the messages nothing added to commit but untracked fils present (use "git add" to track)


You don't "commit the folder" - you add the folder, as you have done, and then simply commit all changes. The command should be:

git add foldername
git commit -m "commit operation"

To Add a little to the above answers:

If you are wanting to commit a folder like the above

git add foldername
git commit -m "commit operation"

To add the folder you will need to be on the same level as, or above, the folder you are trying to add.

For example: App/Storage/Emails/email.php

If you are trying to add the "Storage" folder but you have been working inside it on the email.php document you will not be able to add the "Storage" folder unless you have 'changed directory' (cd ../) back up to the same level, or higher, as the Storage file itself