How to do one way translation with SubGit?
Today we’re going to answer the question that has been asked quite frequently:
We have the SVN repository and we want to translate everything from SVN to Git but we don’t want to translate any Git changes back to SVN, what should we do?
Sometimes this question is asked about round-about situation which doesn’t really make a difference in that case.
To cut it short, it’s impossible even if one can write to both SVN and Git repositories.
I’m sure it’s easy to answer that question for oneself if to imagine two synchronised writable repositories and to both of them changes are being made, but those changes translate only from one repository and not to another. What if some file’s been translated from SVN to Git and then somebody replaced the contents of that file with something completely different in the Git repository?
Consider the example on the picture. The translation is SVN to Git only, not in the opposite direction. Someone changes a file on Git side to ZZ, later appends Y to X on SVN side. After the second change SubGit cannot decide which version should have priority in case of conflicts and the conflicts are rather probably, especially when new Git contents (there’s no way to append Y to X when the content is ZZ) has nothing common with SVN content.
That’s why SubGit does not allow one-way translations at all. The only way one could achieve one-way translation effect is by making one repository read-only (usually it’s Git repository). In such a case when your Git is read-only it’s sufficient to install and use SubGit as usual and common bi-directional translation would become one-way translation only by the fact that nobody could bring any changes to one of repositories.
To make a Git repository read-only one could amend pre-receive or, when SubGit is installed, user-pre-receive hook. It’s enough to write at the end of the file:
echo 'this repo is read-only' exit 1
And that would mean that all the commits are rejected from this repository and changes would be translated only by SubGit and only from SVN to Git.