How to git add a whole folder

My guess is that you are trying to add folder while you already are in folder.

$ cd my_folder
$ git init
$ git add my_folder # this is not going to work

Instead, add everything in the folder, rather than the folder itself:

$ cd my_folder
$ git init
$ git add .

To your other question, adding whole folders is fine, but only relevant when adding sub-folders. Again, you can’t git add the folder that is your repository (my_folder above).

$ cd my_folder
$ ls
my_subfolder  other_things
$ git add my_subfolder # this is fine

The usual way to add everything in your working tree to your repo is git add ..

Leave a Comment