Search code examples
gitgit-svn

Does Git store history when an empty directory was created?


I am converting Subversion to Git recently using git-svn. I know that I have to add .gitkeep to add an empty directory in Git. Does it mean that Git does not store history when a directory was created?

My Subversion repository has many empty directories and if I added .gitkeep to all empty directories for Git, it means that the directories' history wwas seen as if they were created now, not the exact days when the empty directories were created.


Solution

  • No, Git does not store information about directories. git-svn has facilities to take care of this for you.

    git svn clone --preserve-empty-dirs will take care of empty directories for you while cloning. It will create a placeholder file to track empty directories (by default .gitignore) and remove them as appropriate.

    git-svn also stores untracked empty directories. git svn mkdirs can be used after a checkout or reset to recreate empty directories.

    Finally there is the svn-remote.<name>.automkdirs config value to control whether git svn clone and git svn rebase will run git svn mkdirs for you.