A tiny utility to force empty directories into a Git repo.
Project description
gitkeep
Sometimes when working with Git you require empty folders to be part of your repository. Maybe because you want to underline the importance of certain directories for storing certain files in the future. Maybe some part of the logic depends on those directories being there.
However, because Git only versions files, it is unable to add empty directories .
One well known hack to get around this problem is to version dummy files inside the empty directories you wish to add to your repository, in order to force the directory into source control.
Gitkeep is a tiny command line utility written in Python that makes it easy to
use this hack, by creating .gitkeep
files in the directories of your choosing.
In the Bash command line it is the equivalent of running:
find . -type d -empty -exec touch {}/.gitkeep \;
However, using the Bash command above forces you to do the same for each directory path you wish to version, and then to manually delete any exceptions.
Also, Windows users do not have the luxury of the Bash command line unless they install Cygwin.
Install
If you already have Python installed, simply run:
pip3 install gitkeep2
Use
To create a .gitkeep
file in a specific directory called 'foo':
gitkeep path/to/foo
To add a message to your .gitkeep
file in order to let fellow developers
understand why it's important to keep the specified directory in source control
you can use the --message
or -m
flag:
gitkeep path/to/foo -m "This is where we'll later add X stuff."
By default all .gitkeep
files bear the date of creation, the URL to this
project and a default message. The idea here is to help others maintaining your
project in the future understand what these files are. However, if you'd prefer
to create empty .gitkeep
files you can do so with the --empty
or -e
flag:
gitkeep path/to/foo -e
To remove a .gitkeep
file from a specified path use the --let-go
or -l
flag:
gitkeep --let-go path/to/foo
To create .gitkeep
files recursively in a path and all its sub-directories
use the --recursive
or -r
flag:
gitkeep --recursive path/to/foo
To remove all .gitkeep
files recursively from a path and all its
sub-directories use a combination of the -r
and -l
flags above:
gitkeep -lr path/to/foo
Implementation Notes
Gitkeep is powered by Click.
Develop
First prepare a virtual environment to install your local copy. From the root of your project run:
virtualenv venv
New python executable in venv/bin/python
Installing setuptools, pip............done.
Activate the corresponding environment. On OS X and Linux, do the following:
. venv/bin/activate
Notice the prompt of your shell has changed to show the active environment.
Get Click installed in your virtual environment:
pip3 install Click
To install gitkeep in your virtual environment:
pip3 install --editable .
Then just try running gitkeep:
gitkeep --help
To go back to the real world, run:
deactivate
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file gitkeep2-1.0.0.post1.tar.gz
.
File metadata
- Download URL: gitkeep2-1.0.0.post1.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b1f644972fd89508b090f647534e44d682832d859eef05d431adc314bcadf28 |
|
MD5 | 5c088b43cd7d2c68d2140547ee216ee0 |
|
BLAKE2b-256 | fe1e9cc728d2d8236eb6418e58da42cbcea04d66b5c14ef1085d4f7f0ec2b834 |