Directory Layout Issue
I’m working with an SVN repo through git and facing a tricky merge situation. My main trunk has this structure:
ui/
server/
+ module1
+ module2
But on a feature branch, someone moved the subfolders and changed everything to:
module1/
module2/
They basically took module1 and module2 out of the server folder and put them at root level, then removed the ui and server directories completely.
The Problem
Now I need to merge this branch back to trunk but keep it organized under the server folder like it was before. The catch is I can’t lose the commit history from that branch. I’m using git as my frontend to work with the subversion repo.
Has anyone dealt with this kind of folder restructuring merge before? What’s the best approach to maintain the history while getting the files back where they belong?
Wait, have you tried git subtree? It might handle path changes better than filter-branch. Also, what happened to the ui folder on your feature branch - did you lose any content there? How big are these modules? That’ll affect which merge strategy works best.
this is messy but totally doable. use git filter-branch on your feature branch to rewrite the paths back to server/module1 and server/module2 before merging. it’s scary but preserves all commits and makes the merge clean. back up everything first - you dont want to mess up your history.
Had the same problem last year with git-svn. You need to use git’s history rewriting before merging. I created an intermediate commit on my feature branch that moved files back where they belonged using git mv module1/ server/module1 and git mv module2/ server/module2, then rebuilt the ui directory structure. This keeps all your commit history while fixing the file locations. Once that’s done, merging into trunk is easy since everything lines up. Git-svn handles this fine, and when you push to SVN, all your feature branch commits stay intact. Just test that intermediate branch hard before merging - you don’t want to break existing trunk code that expects the server structure.