BACKGROUND
We have an SVN repository with multiple projects:
ROOT
- Project1
- trunk
- Project2
- trunk
..etc
Then we started a migration to git. We setup subgit to keep SVN and GIT repositories in sync (both-ways). For a few months already, we had some developers using svn and some using git, apparently without any problem.
Each of the projects above became a git repository, with subgit configured as:
trunk = trunk:refs/heads/master
branches = branches/*:refs/heads/*
tags = tags/*:refs/tags/*
shelves = shelves/*:refs/shelves/*
So far so good. Let's focus on Project1 from now on.
PROBLEM
I noticed that some of the recent commits done in svn were not ported to git. Looking at the logs on the svn side, I found out those commits are in an "inconsistent" state in svn as well (log partially anonymized):
$ svn log -v Project1
------------------------------------------------------------------------
r6109 | user1 | 2015-01-13 12:47:43 +0100 (di, 13 jan 2015) | 1 line
Changed paths:
R /Project1/trunk (from /Project1/trunk:5477)
Branch '/trunk' replaced from /trunk:5477
------------------------------------------------------------------------
r6089 | user2 | 2015-01-08 13:46:27 +0100 (do, 08 jan 2015) | 1 line
Changed paths:
M /Project1/trunk/src/com/....
-- fix xyz
------------------------------------------------------------------------
r5978 | user2 | 2014-12-26 21:30:28 +0100 (vr, 26 dec 2014) | 4 lines
Changed paths:
M /Project1/trunk/src/com/...
-- fix abc
------------------------------------------------------------------------
[ ... more commits ... ]
------------------------------------------------------------------------
r5477 | user2 | 2014-10-16 17:07:25 +0200 (do, 16 okt 2014) | 1 line
Changed paths:
M /Project1/trunk/src/com/...
-- fix bug23
Now, the last commit r6109 looks scary. It seems to say that the current trunk has been overwritten by r5477.
Indeed, the log of the trunk folder completely misses the revisions in between:
$ svn log -v Project1/trunk
------------------------------------------------------------------------
r6109 | user1 | 2015-01-13 12:47:43 +0100 (di, 13 jan 2015) | 1 line
Changed paths:
R /Project1/trunk (from /Project1/trunk:5477)
Branch '/trunk' replaced from /trunk:5477
------------------------------------------------------------------------
r5477 | user2 | 2014-10-16 17:07:25 +0200 (do, 16 okt 2014) | 1 line
Changed paths:
M /Project1/trunk/src/com/...
-- fix bug23
QUESTION
I'd like some help with identifying the current status and possible solutions.
What I think has happened (please help me here!):
- at some point, a developer using git on the same source has used a
git reset --hard
to reset the working copy to the local master branch which was at the commit corresponding to the svn r5477, and pushed this to the remote master. - this, translated by subgit, resulted in the svn revision 6109, which says "Branch '/trunk' replaced from /trunk:5477"
- Because the git repository is mapped to
Project1/trunk
, this has been rewritten with r5477 - However, the folder
Project1
is not even seen by subgit, which explains why the history ofProject1
still contains the log of the now missing commits (the code in trunk is actually back to the r5477 revision).
Can anyone confirm that this is likely to be the current state? Am I still overlooking something? I didn't know that svn could allow you (subgit in this case) to end up with inconsistent histories.
If this is true, could anyone suggest what the best solution could be?
Mind that the git repository does not have that part of the history, because it only syncs Project1/trunk
and not Project1
.
I have the feeling this should be fixed in the svn repository. But I don't know how.
Is the following a possible solution?
$ cd Project1
$ svn merge -rHEAD:6089 .
$ svn ci
Warnings and/or better suggestions anyone?