GIT SVN: fetching a recreated SVN branch without merging the parent incorrectly

I have the following situation with my upstream svn repository:

I created the svn branch and worked a bit on it, which led to a really confusing story. So I deleted it again, retaining git commits, which allowed me to clear the history well.

As soon as I had the finished patch series, I set aside my branch using svn copy and then git svn fetch . The idea was that I would then reinstall the cleared story onto a new svn branch so that I can easily publish it using git svn dcommit .

However, git svn fetch did not do what I expected. This is what I expected (fake git log --oneline --decorate --graph output):

 * xxxxxxx (svn-branch) * xxxxxxx (svn-parent-branch) ... somewhere further down, unrelated to the above * xxxxxxx (old-svn-branch-head) 

But this is what I got:

 * xxxxxxx (svn-branch) |\ | * xxxxxxx (svn-parent-branch) | * xxxxxxx (old-svn-branch-head) 

As you can see, git svn fetch completely ignored the fact that the svn branch was removed, matching the recreation of svn with the merge commit in git . Now I wouldn’t bother about it if it didn’t matter, but, unfortunately, the wrong connection confuses git merging algorithms, creating conflicts with fictitious merging when a new database commit is reloaded.

So my question is: how can I lure git svn fetch so that I don't associate the new transaction with the database with the wrong parent or somehow fix my git repository so that I can still publish my stuff with git svn dcommit ? Of course, I can always delete all this again and create a new svn branch with a different name, but I was wondering if a better solution exists.

+5
source share
1 answer

I faced a similar situation and still could not find a way to disable this behavior ( --no-follow-parent disables tracking of the entire branch, which I do not want).

I ended up with a git replace --graft . He creates a replacement fixation and keeps his children intact . After replacing (e.g. git replace --graft svn-branch svn-parent-branch ) this is what you see:

 * svn-branch | * svn-parent-branch ... * old-svn-branch-head 

You can still see the original commit with the gitk --all option.

 * svn-branch (replacement) | | * svn-branch (original) |/| * | svn-parent-branch | | | * old-svn-branch-head ... 
+2
source

Source: https://habr.com/ru/post/1236804/


All Articles