Git is a popular, distributed version control system that is used by developers and organizations. It tracks all files & folders in your code base as well as any changes made in them. But sometimes you may need to add blank directory in git repository. In this article, we will learn how to add blank directory in git repository.
How to Add Blank Directory in Git Repository
Typically, git does not allow you to add blank directory to git repository. You can create a new folder in your local code repository but it will not be added to the list of untracked or tracked items, by default.
So you need to create a .gitignore file (note the dot at the beginning of filename) in this blank directory with the following content in it.
# Ignore everything in this directory * # Except this file !.gitignore
The first line above will make git ignore all contents of the directory. The second line will ensure that only .gitignore file is included in the repository.
So here are the complete list of steps. Go to your repository’s folder. Create a new folder /tmp.
$ mkdir tmp
Create a .gitignore file in it with the following command.
$ touch tmp/.gitignore
Add the newly created folder using the following command.
$ git add tmp
Add the above mentioned text to newly created gitignore file.
$ echo '*' > tmp/.gitignore $ echo '!.gitignore' >> tmp/.gitignore
Finally, commit the blank directory.
$ git commit -m 'Empty directory' tmp
In this article, we have learnt how to add blank directory in git repository.
Also read:
How to Iterate Through Files in Directory in Python
How to Find All Text Files in Directory Using Python
How to Convert CSV to Tab Delimited File in Python
How to Stress Test Linux Server
Schedule Cron Job to Run Every 1 Hour
Related posts:
Sreeram has more than 10 years of experience in web development, Python, Linux, SQL and database programming.