Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
+3 votes
2 views
in DevOps and Agile by (19.4k points)

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 files present (use "git add" to track)

2 Answers

+2 votes
by (27.5k points)

First of all, I would like to point out the command error while performing the commit operation. 

We don't commit folders, the commands should look like this: 

$ git add foldername

$ git commit -m "commit operation"

Now there's one more thing you need to keep in mind, which is to commit the folder you need to be on the same level as, or above, the folder you are trying to add. For instance: App/Download/Files/new.php

If you are trying to add the "Download" file but you have been working inside on the new.php document, then, in that case, you won't be able to add the "Download" file. You have to 'changed directory' (cd ../) back up to the same level, or higher, as the Storage file itself. 

git add all files in folder - how to git commit a whole folder?
Intellipaat-community
by (9.6k points)
worked like a charm.
0 votes
by (2.8k points)

To specifically add all the files present in a folder, we use (.) operator:

Git add .

Then, to commit all the files we use : 

Git commit -m “custom message”

1.2k questions

2.7k answers

501 comments

693 users

Browse Categories

...