Merging an independent Git repo with another Git repo that is a conduit with Subversion: avoiding duplication when merging
I am happily developing a Django project in my own Git repo on my localhost. I am creating branches, committing and merging happily. The path is something like:
and the structure is:
project ├── README ├── REQUIREMENTS ├── __init__.py ├── fabfile.py ├── app1 ├── manage.py ├── app2 ├── app3 ├── app4 └── project
The rest of my development team still use Subversion, which is one giant repo with multiple projects. When I am working with that on my localhost I am still using Git (via git-svn). The path is something like
Projects live under this like:
giant-svn-repo |── project1 |── project2 |── project3 └── project4
When I want to work with the latest changes from the remote svn repo I just do a git-svn rebase. Then for new features I create a new branch, develop, commit, checkout master, merge branch with master, delete branch, and then a final git-svn dcommit. Cool. Everything works well.
These two repositories (lets call them git-django and git-svn) are completely independent right now.
Now I want to add git-django into the git-svn repo as a new project (ie. in a child directory called djangoproject). I have this working pretty well, using the following workflow:
- cd into git-svn repo
- Create a new branch in the git-svn repo
- Make a new directory to host my django project
- Add a new remote that links to my original Django project
- Merge the remote into my local directory
- Read-tree with the prefix of relative path djangoproject so it puts the codebase into the correct location based on the root of git-svn repo
- Commit the changes so everything gets dumped into the correct place
From the command line this looks like:
> cd /path/to/giant-svn-repo > git checkout -b my_django_project > mkdir /path/to/giant-svn-repo/djangoproject > git remote add -f local_django_dev /path/to/git/django/project > git merge -s ours --no-commit local_django_dev/master > git read-tree --prefix=djangoproject -u local_django_dev/master > git commit -m 'Merged local_django_dev into subdirectory djangoproject'
This works, but in addition to the contents of the django git repo being in /path/to/giant-svn-repo/djangoproject it is also in the main root of the repository tree!
project ├── README ├── REQUIREMENTS ├── __init__.py ├── fabfile.py ├── djangoproject │ ├── README │ ├── REQUIREMENTS │ ├── __init__.py │ ├── fabfile.py │ ├── app1 │ ├── manage.py │ ├── app2 │ ├── app3 │ ├── app4 │ └── project ├── app1 ├── manage.py ├── app2 ├── app3 ├── app4 └── project
I seem to have polluted the parent directory where all the projects of the giant-svn-repo are located.
Is there any way I can stop this happening?
(BTW this has all been done in a test directory structure – I haven’t corrupted anything yet. Just trying to figure out the best way to do it)
I am sure it is just (re)defining one more argument to either git merge, git read-tree or git commit but I am pretty much at my limit of git kung-fu.
Thanks in advance.