how to add subdirectories in git

git sub directory

Adding subdirectories in existing git repository

You have done git push but the new folders didn’t got pushed. What happened?

Having new folders and subfolders in the git repository, but the files under those not showing in the server?

Adding subdirectories in existing git repositories should have been direct right? But, sometimes it is not. I will show you How to add subdirectory in existing git repository

Let’s say you have existing git repository my-git-repo and you want to add new folder under it: new-folder/another-sub-folder

Step by steps to add git subdirectories in existing git repository

1. Create folder in the repository you are going to create new folders

mkdir -p new-folder/another-sub-folder

2. Now if you do git status you will see the new folder under new listing.

3. Create a file under another-sub-folder otherwise git won’t show nothing.

cd new-folder/another-sub-folder && touch some-file.xml

4. Go to another-sub-folder and issue git init

5. Now go back to the root of the folder and issue git add new-folder/

6. You are done, when you do git status you will see your new files being listed for commit.

See changes in Git after staging change

Updating Git on Mac showing previous version

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*