Git: How to recursively add the files in a directory

If you are working with Git and want to add a new file or directory, follow the following steps

Go to the directory where your files are located.

$ cd directory
$ git add *

Now you must commit these changes (You can give necessary comments)

$ git commit -m "Adding new files"

If you want to add a directory and all the files which are located inside it recursively, Go to the directory where the directory you want to add is located.

$ cd directory
$ git add directoryname

Now you must commit these changes (You can give necessary comments)

$ git commit -m "Adding a new directory"

Note that the above step will commit recursively the subdirectories and files present in the directory.

Advertisements