git

How to stage all files in if a subfolder on git


May I know how to stage all the files in a folder like a folder called subfolder on git?

Have tried

git add subfolder/\\*

but doesn't work.


Solution

  • Just use git add subfolder.

    I usually use git add . in the root of the repository to stage all files in the repo.

    If you want to use the asterisk, you should use git add subfolder/* because the shell will expand this into git add subfolder/foo subfolder/bar subfolder/... with all the files in the directory.

    When using git add subfolder/\\*, the shell won't expand the asterisk, which will cause it to call git add subfolder/* which tries to add a file called * in the subfolder.