From: David Reitter Date: Fri, 27 Mar 2009 16:56:43 GMT Subject: Re: How to merge by subtree while preserving history? Message-ID: In-Reply-To: <20090327073847.GE27459@genesis.frugalware.org> On Mar 27, 2009, at 3:38 AM, Miklos Vajna wrote: > Now do a 'git log f474c52..52b8ea9' and you'll see the merged commits. Sure :) Needless to say, this is not practical and doesn't support people's workflow. For simple renames, "git log --follow" helps, but as soon as you want to do a "diff" in one of the listed revisions, filtering for just this one file, then history becomes invisible again. Concretely, this breaks the common workflow with C-x C-v l, then "d" in Emacs. I'm aware of the content-tracking vs. file-tracking discussion; it's all fine, except that file names are meaningful meta-data for some content, at least in some projects. Is there a command that gives me the diff for a revision pair, restricted to what happened to content in a given file in the current tree? > But you are right about that 'git log -- path' will find the merge > commits only (which is right, as the tree objects are not modified > when > merging, just the resulting tree has the original tree in a > subdirectory). > > If this is a one-time operation then I would just use git filter- > branch > to move the code to a subdir. For the record: In the meantime, I managed to move the original file in the CVS repository (by just moving all the ",v" files and getting rid of CVSROOT/history, which doesn't seem needed). The I re-ran cvsimport, mitigating a bunch of problems with "cvsps". For the record, cvsps / cvsimport could not handle the case where my repository named "foo" had a subdirectory also called "foo", in which I moved all the stuff. I had to rename the directory to "bar". I also had to delete cvsps's cache file with the -x argument (or delete it from the surprising location ~/.cvsps). Then, I merged with "git pull", noting the rev ID before the merge. Next, I used "git filter-branch" to rename the directory again from BAR to FOO as follows: git filter-branch --index-filter \ 'git ls-files -s | sed "s-BAR/-FOO/-" | GIT_INDEX_FILE=$GIT_INDEX_FILE.new \ git update-index --index-info && mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE' .. Finally, I had to "git gc" to prune a 200MB worth of objects (it told me I had 500k objects overall). -- http://aquamacs.org -- Aquamacs: Emacs on Mac OS X