GitHub: creating a directory while adding on-line adding a file or uploading file(s)
Posted by jpluimers on 2025/03/20
Since git doesn’t have the notion of directories as entities, neither does GitHub.
This makes it counter-intuitive to add a sub-directory when creating a new file on-line in the GitHub web-UI or uploading file(s) there.
I wanted to do this as instead of taking the local route, it was easier to on-line add and edit [Wayback/Archive] GitHub – jpluimers/https-imgur.com-a-bmw-e61-remote-fix-sWdk0: Content from https://imgur.com/a/bmw-e61-remote-fix-sWdk0 for Wayback Machine archival.
The GitHub web-UI can indeed do this:
- [Wayback/Archive] How do I create a folder in a GitHub repository? – Stack Overflow
TL;DR Use
/in the file name field to create folder(s), e.g. typingfolder1/file1in the file name field will create a folderfolder1and a filefile1. - [Wayback/Archive] How to upload an entire folder? · community · Discussion #21962 · GitHub
you should just try to drag and drop your entire folder in the webui and it will upload whole folder.
Further reading
You can also do this from the git command-line, by adding an empty file in the directory first. By convention, usually a .gitkeep file is used for that though others use .gitignore files for it.
nx based systems by default don’t show files starting with a . (period/dot): these files even are called dot files, so this is a convenient way.
More on this for instance at:
- [Wayback/Archive] How to add an empty directory in git
- [Wayback/Archive] git – What are the differences between .gitignore and .gitkeep? – Stack Overflow
- [Wayback/Archive] What is .gitkeep? How to Track and Push Empty Folders in Git
Queries
- [Wayback/Archive] github create directory online – Sök på Google
- [Wayback/Archive] github create directory online while uploading files – Sök på Google
- [Wayback/Archive] git has no notion of directories only files – Google Search
- [Wayback/Archive] gitkeep – Google Suche
--jeroen






Leave a comment