如果您的工作流只需要一个现有目录,可能会转储其中的文件,那么没问题(还)。但是如果您想进一步处理文件,那么可能会出现问题。因为在目录中不仅有您想要的文件,而且还有一个流氓.gitkeep或README或您拥有的文件。这可能会使简单的bash结构复杂化,例如for file in dirname/*,因为您需要排除或特例额外的文件。
mkdir --parents .generated/bin ## create a folder for storing generated binariesmv myprogram1 myprogram2 .generated/bin ## populate the directory as needed
$ gitkeep --helpUsage: gitkeep [OPTIONS] PATH
Add a .gitkeep file to a directory in order to push them into a Git repoeven if they're empty.
Read more about why this is necessary at: https://git.wiki.kernel.org/index.php/Git_FAQ#Can_I_add_empty_directories.3F
Options:-r, --recursive Add or remove the .gitkeep files recursively for allsub-directories in the specified path.-l, --let-go Remove the .gitkeep files from the specified path.-e, --empty Create empty .gitkeep files. This will ignore anymessage provided-m, --message TEXT A message to be included in the .gitkeep file, ideallyused to explain why it's important to push the specifieddirectory to source control even if it's empty.-v, --verbose Print out everything.--help Show this message and exit.
# Ignore files but not directories. * matches both files and directories# but */ matches only directories. Both match at every directory level# at or below this one.*!*/
# Git doesn't track empty directories, so track .keepdir files, which also# tracks the containing directory.!.keepdir
# Keep this file and the explanation of how this works!.gitignore!Readme.md
# Initialize new GIT repositorygit init
# Set author data (don't set it as part of the `git commit` command or your default data will be stored as “commit author”)git config --local user.name "Nobody"git config --local user.email "none"
# Set both the commit and the author date to the start of the Unix epoch (this cannot be done using `git commit` directly)export GIT_AUTHOR_DATE="Thu Jan 1 00:00:00 1970 +0000"export GIT_COMMITTER_DATE="Thu Jan 1 00:00:00 1970 +0000"
# Add root commitgit commit --allow-empty --allow-empty-message --no-edit