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:

/path/to/git/django/

and the structure is:

  • Using docker-compose to collaborate on existing git repo Django project
  • Django Jenkins raises WebDriverException when processed to Selenium server
  • Which PIP Returns Global Instead of VirtualEnv
  • Best way to (git) clone app into Django project directory
  • error in deploying django app to heroku from windows
  • same project, multiple customers git workflow
  • 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

    /path/to/giant-svn-repo/
    

    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:

    1. cd into git-svn repo
    2. Create a new branch in the git-svn repo
    3. Make a new directory to host my django project
    4. Add a new remote that links to my original Django project
    5. Merge the remote into my local directory
    6. 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
    7. 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.

  • Merge two git repos into one without renaming files
  • Trying to clone a repo using git protocol leads to https error?
  • Versioning multiple projects with versioneer within a single git repository
  • Get the time and date of git tags
  • What does “Warning : There are multiple branch changesets here” mean?
  • GitHub network graph representing wrong first parent after merge
  • Git Baby is a git and github fan, let's start git clone.