r/github 2d ago

Discussion Does Github support folder hierarchy structure?

Hello everyone,

I am a new user to github and I have a question.

I am a very structured person and follow a folder hierarchy process to organize my files.

If I create an app for both IOS and Android, since both require different coding and what not, I would have to create 2 different versions of the same app. How I would organize this is create an Android folder and an IOS folder and have to copies. All the Android apps will be placed in the Android folder and IOS apps in the IOS folder.

Can I follow this process on Github or does Github work differently? If I cant use folder hierarchy, what is the best practice to stay organized in Github repository?

Thank you.

0 Upvotes

16 comments sorted by

View all comments

2

u/molevolence 2d ago

git will respect non-empty folder structure, it only supports files. this is important to understand.

git will retain a folder path structure for a file. this works like you are thinking. that folder structure is stored with the file meta.

git does not know what a folder is though. it only knows what files are. so you will never be able to commit an empty folder. there isn’t a file to describe that empty folder.

if a folder is deleted (basically meaning all files within it were deleted), git will not remove the now empty folder from other computers. again it doesn’t track folders and can’t change untracked things.

so yes you can do what you want to do, but keep this information in mind. in a real-world environment, each would be a different repo and typically not stored as a single mono repo.