I want to create a folder in a GitHub repository and want to add files in that folder. How do I achieve this?
Create a new file, and then on the filename use slash. For example
Java/Helloworld.txt
Here is an easy and quick, presently available browser approach to creating folders inside a repository
1)Click the repository / create a new repository.
2)Click create Add file and then create a new file.
3)Give the folder name you want to create with a ' / ' mark and then add a file in it
4)Commit the changes
Click here for the visual representation of the above steps in order.
You just create the required folders in your local repository. For example, you created the app
and config
directories.
You may create new files under these folders.
For Git rules:
Git command to do commit:
git add app/ config/
git commit
Then give the commit message and save the commit.
Then push to your remote repository,
git push origin remote
Git doesn't store empty folders. Just make sure there's a file in the folder like doc/foo.txt and run git add doc
or git add doc/foo.txt
, and the folder will be added to your local repository once you've committed (and appear on GitHub once you've pushed it).
Actually GitHub does not create an empty folder.
For example, to create a folder in C:\Users\Username\Documents\GitHub\Repository
:
Create a folder named docs
Create a file name index.html
under docs
Open the GitHub for desktop application
It will automatically sync, and it will be there.
To add a new directory all you have to do is create a new folder in your local repository. Create a new folder, and add a file in it.
Now go to your terminal and add it like you add the normal files in Git. Push them into the repository, and check the status to make sure you have created a directory.