Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clone CVS repository with empty directories

I convert a CVS repository to a Git repository with the following command:

$ git cvsimport -vaikd :pserver:[email protected]:2401/ -C IVR-GUI GIT

However, Git ignores the empty directories in the CVS repository. But I want the repository to be cloned including those empty repositories. How can I make Git to do that?

like image 641
thillaiselvan Avatar asked Aug 10 '12 03:08

thillaiselvan


1 Answers

Git cannot track empty directories, so they're not brought over in the CVS-Git conversion. From the Git FAQ: "Directories are added automatically when adding files inside them." Your directories don't appear because Git isn't tracking anything within them.

How to track empty repositories in Git

One workaround to track empty directories is to place an empty file, like .gitkeep in each empty directory (.gitkeep is used by convention, but you can name this file anything you want). Track the files, then you'll be able to clone empty directories. There are a few other ways to add empty directories to a Git repository.

Manually copy empty files from a pre-existing CVS repository

The following command will copy all empty directories in your cvs repo to your Git repository (substitute the dummy directory paths)

$ find ~/cvs_repo -type d -empty -exec cp -r {} ~/git_repo/ \;

You can then add these empty directories to your project with your workaround of choice, and follow up with something like $git commit -m "Add empty directories to repository".

Automating the procedure with cvsimport?

Now, I would assume that cvsimport would compensate for this difference in VCS (CVS lets you track empty directories, Git does not). I don't know anything about the tool, but maybe there's an option you can pass to have it automatically handle adding empty directories.

like image 115
David Cain Avatar answered Oct 22 '22 15:10

David Cain