I'm resurrecting a rather old code project, from when I was using CVS regularly, as a component in a new project that I've already been working on using git. I still have access to the CVS archive the old project's module is in, so I was just going to use git-cvsimport to get the commit history and go from there. However, this is just creating a new git repository inside of the current one. It's entirely possible I need to do this as a multistep process where I go CVS -> fresh git repository and then use something else to get it into the existing git repository.
Running this in newproj/newsubdir ($CVSROOT is already correctly set in my shell configuration):
git cvsimport -k -o master -u -s \- -A ~/Documents/cvs-authors.txt oldproj
gets me a brand new repository newproj/newsubdir/.git/ with all of the correct commits (comments, timestamps, history), and with HEAD where I want it.
What I want is for the historical CVS commits to be as if they were always in newproj/newsubdir/oldproj-file1, newproj/newsubdir/oldproj-file2, etc. In my experience, git has the magic to do this kind of thing, but I couldn't find an obvious fit to my situation.
You can use git-cvsimport to import your CVS repository into Git. By default, this will check out every revision, giving you a relatively complete history. Depending on your operating system, you may need to install support for this separately. For example, on an Ubuntu machine you would need the git-cvs package.
Import into a new repoSelect Repos, Files. From the repo drop-down, select Import repository. If the source repo is publicly available, just enter the clone URL of the source repository and a name for your new Git repository.
The git fetch command downloads commits, files, and refs from a remote repository into your local repo. Fetching is what you do when you want to see what everybody else has been working on.
You have three options. All of them start with doing the clean cvsimport, so go ahead and do that.
Number one means that the outer project relies on the inner, but is probably not desirable for you.
Number two is explained in this subtree merge howto. It might be good enough for you.
But if you like a nice clean linear history, you can do #3 and tangle them up for good. I did something similar in a cleanup project a while back and have a lot of the documentation and tools still there.
The basic idea was to separate all of the changes into a patch history that would reconstruct the changes. By default, this history is in a sort of repository order, but running the script I mentioned in the post will rearrange the patches into a new sequence in chronological order.
The tree hash should let you know you didn't break anything other than the lineage.
Were I to do this again, I'd possibly just emit a grafts file and do a filter-branch
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With