GIT SVN: fetching a recreated SVN branch without the wrong merge parent

cmaster - reinstate monica

I have the following situation with my upstream svn repository:

I created an svn branch and did some work on it which led to a really convoluted history. So I deleted it again, retaining the git commits, which allowed me to clean up the history quite nicely.

Once I had my patch series ready, I recloned my branch using svn copy, followed by a git svn fetch. The idea was, that I would then rebase the cleaned up history onto the new svn branch, so that I could easily publish it with 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 see, git svn fetch completely ignored the fact that the svn branch was deleted, mapping the recreating svn commit to a merge commit in git. Now, I wouldn't fuss about this, if this were of no consequence, but unfortunately, the wrong connection confuses git's merge algorithms, creating bogus merge conflicts when rebasing across the new branch base commit.

So my question is: How can I entice git svn fetch to not link up the new branch base commit with the wrong parent, or somehow fix my git repo in a way that I retain the ability to publish my stuff with git svn dcommit? Of course, I can always delete the whole thing again, and create a new svn branch with a different name, but I was wondering whether a better solution exists.

snipsnipsnip

I encountered a similar situation and still couldn't find a way to turn off this behavior (--no-follow-parent turns off the whole branch tracking, which is not what I want).

I ended up fixing history with git replace --graft. It creates a replacement commit and keeps its children unchanged. After the replace (ex. 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 gitk --all option.

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

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Git-svn: how to partially merge svn-branch in git

From Dev

Wrong(?) branch prefixes migrating SVN to Git

From Dev

"git svn rebase" without changing the current branch

From Dev

"git svn rebase" without changing the current branch

From Dev

svn to merge trunk into branch

From Dev

svn to merge trunk into branch

From Dev

svn to git branch to branch syncing

From Dev

Need to merge a git branch forcefully onto the master after svn import

From Dev

How to merge SVN branch to trunk?

From Dev

SVN replace branch with another - NO merge

From Dev

SVN Branch To Trunk Merge Issue

From Dev

Create a Tag and Merge with a branch SVN

From Dev

svn merge with renamed directory in branch

From Dev

Is it possible to change the parent of an SVN branch?

From Dev

git svn create a new svn branch based on a git branch

From Dev

merge svn feature branch to release branch

From Dev

What branch to git svn rebase on?

From Dev

git-svn local branch tracking remote svn branch

From Dev

git-svn local branch tracking remote svn branch

From Dev

svn update VS git merge

From Dev

Android Studio - unable to merge from SVN branch

From Dev

Tortoise SVN - Merge Trunk into Branch - Tree Conflict

From Dev

SVN Merge branch to trunk with ignored versioned files

From Dev

SVN - Merge working copy into another branch

From Dev

the command git branch for svn-git on cygwin

From Dev

the command git branch for svn-git on cygwin

From Dev

Migrating a single branch from SVN to Git

From Dev

Track a branch in a bare git-svn

From Dev

unlink git branch from svn origin