Git add all files in folder-Recursively add the entire folder to a repository

1.5K    Asked by Yashraj in Salesforce , Asked on Jul 6, 2021

I am trying to add a branch to the master branch on GitHub and push a folder onto that branch.

The folder structure of the branch looks like - SocialApp/SourceCode/DevTrunk/SocialApp and all the source code files are in the last folder.

I am using the following Git commands:

git add *
git commit -m with the message
git push

This is pushing only the first folder "SocialApp" onto GitHub and ignoring the folder SourceCode that is inside the folder. How git add recursive?

Answered by debbie Jha

For this case:

Go to .gitignore file and check whether the subdirectory is ignored or not ignored.

And then you could do:

git add --all

git commit -am ""

git push

This will add the entire folder to a repository.

Note: To recursively add all files or folders and also sub folders to the staging area of git, we can either call “git add -A” or “git add –all”, it will add all files in the project workspace to the staging area, irrespective of location from where this command is executing.



Your Answer

Interviews

Parent Categories