How to Push an Empty Git Folder or Directory Example

preview_player
Показать описание
Are you struggling to push empty Git folder to remote GitHub, GitLab or BitBucket directories? You're not alone. The fact that Git will not push an empty directory to other repositories has bewildered many a developer. There's not real solution, but there is a commonly accepted workaround. The unwritten convention is to simply add a .gitkeep file to the empty folder and push it. Sure, it's not really an empty Git folder if there's a file in it, but it servers the purpose. So if that's your issue, this quick push empty Git directory example should get you on your DVCS way.
Рекомендации по теме
Комментарии
Автор

Your videos have been a Godsend ! Thank you so much !

ejiroolokpa
Автор

Configuration files needs to be tracked and committed only once. How can we prevent/freeze future commit on Configuration Files by other users who cloned it ? How do I make Git stop tracking Configuration files, in a way that configuration files should remain in the repository server so that if someone new clones the repo, they should get the file but changes done by that someone new should not be tracked or atleast should not be committed to git remote server ?

mitravindgarg
Автор

Would have been nice to include expected structures in the .gitignore file, so even if they're not explicitly represented in the repository they would be created during cloning.

bionoid
Автор

Thanks for the info! However, at this point, it's not really an empty folder though, right?

The reason I ask is I'm using python to read everything that is a folders in a script. I don't want python to read that file. I guess I could go into my script and specifically tell python to ignore the file ".gitkeep" but I'm hoping I wouldn't have to update all my code to ignore that file. Any other pointers on that? THANKS SO MUCH

goldensleeves
Автор

What if you want to push a folder but ignore its content ?

licocup
Автор

There's a full write up on how to git push empty folders and directories over on TSS:

cameronmckenzie