Closed kaiyuan01 closed 8 years ago
You can use the git add
command for a directory as you can for a file:
git add mydirectory
http://git-scm.com/docs/git-add
Then you will need to commit as usual:
git commit
Finally push:
git push -u origin mybranch
Git, due to its design, doesn't track empty folders -- git only tracks files. Files can be inside folders, but an empty folder, by itself, is "invisible" to Git.
In software development, it's common for projects to need an empty folder to be part of the project (a log
directory, say, where the program can write log files, might need to exist on disk, even if we don't actually ever want to track log files in version control).
The convention for managing this in Git is to create a hidden file inside the folder you want to track. Files beginning with a "." (a period or dot) are treated as hidden files, so the convention is:
mkdir folder-to-track
touch folder-to-track/.gitkeep
git add folder-to-track
Thanks @jaw6 for the clarification
:+1: