How to commit and push an empty git folder

Introduction

In this tutorial, How to commit and push an empty folder or directory to the Git repository. Git cannot add a completely empty directory. Git doesn’t like empty folders. Using .gitkeep to commit or push an empty directory to GitHub or GitLab.

What is .gitkeep?

It is to solve the problem of Git not pushing empty folders to remote DVCS Repos like GitHub or GitLab. To get Git to recognize an empty directory, the unwritten rule is to put a file named .gitkeep in it.

What are the differences between .gitignore and .gitkeep?

  • .gitkeep to track empty directories.
  • .gitignore file is used to list files that should be ignored by the git when looking for untracked files.

How to do it!

Follow these steps to use the .gitkeep file.

$ mkdir empty-folder
$ cd empty-folder
$ touch .gitkeep
$ git add .
$ git commit -m "How to Commit empty folder in Git with gitkeep file"
$ git push origin

Conclusion

You have committed and push an empty folder or directory to the Git repository. I hope will this your helpful. Thank you for reading the DevopsRoles page!

, , ,

About HuuPV

My name is Huu. I love technology and especially Devops Skill such as Docker, vagrant, git so forth. I likes open-sources. so I created DevopsRoles.com site to share the knowledge that I have learned. My Job: IT system administrator. Hobbies: summoners war game, gossip.
View all posts by HuuPV →

Leave a Reply

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

Comment moderation is enabled. Your comment may take some time to appear.

This site uses Akismet to reduce spam. Learn how your comment data is processed.