2

I'm trying to convert an old CVS repository tracking a vendor branch to git, and I'm running into a merge issue.

The repository is structured like this:

dir1/
dir2/

dir2 comes from the upstream branch. Upstream converted to git already, and dir2 in our repo is the root of their git repo. I want to add them as a remote and merge their root into the subdirectory dir2.

Simple merging won't work: git treats their root as our root and finds no files in common.

Subtree merging won't work: you can't subtree merge into an existing directory. I followed the How to use the subtree merge strategy guide, and this command fails:

git read-tree --prefix=dir2/ -u upstream/master

The problem is that it detects 'conflicting' files that already exist in dir2. I know the files exist, I want it to merge those files.

Any advice would be appreciated.

4

1 回答 1

2

诀窍是使用 subtree 选项进行正常的递归合并:

git merge -s recursive -Xsubtree=dir2 upstream/master
于 2010-09-02T23:54:37.473 回答