Subgit migrate newer Svn revisions to existing Gitlab Project

70 views Asked by At

My co-worker has previous migrated "project A" from Svn to Gitlab, and numerous other projects use "project A" as submodule.

However, since last migration, some changes have been made in "project A" in Svn, and now I am trying to migrate those newer changes from Svn to the exist Gitlab project that my co-worker created last time.

I can not simply re-migrate the entire "project A" because doing so would change the commit hash, thus "project A" can no longer be a submodule unless I change all other projects.

Is this possible with subgit? I tried subgit import --minimal-revision revision_number --svn-url which would allow me to copy a specific revision in svn for "project A" but I do not know how I would add this to my existing gitlab project?

2

There are 2 answers

0
VonC On

If you need to import only one (or a very few) specific revision(s) from SVN to GitLab, you could simply:

  • clone the GitLab repository
  • clone (with SVN directly, no subgit involved) the SVN repository and make sure it reflects the revision you want to import
  • import one revision into the local Git repository

Set the right author/email

export GIT_AUTHOR_NAME=<the Author name from SVN revision>
export GIT_AUTHOR_EMAIL=<the Author email from SVN revision>

Import:

cd /path/to/local/Git/repository
# make sure your .gitignore includes `.svn/`
git --work-tree=/path/to/local/SVN/repository add .
git commit -m "Import revision"
# if you are done
unset GIT_AUTHOR_NAME
unset GIT_AUTHOR_EMAIL
0
ildar.hm On

it is possible to do with SubGit as well, in the way you mentioned: first, import revisions that you need in a partial new repository using SubGit's minimalRevision setting to not to import the whole repo; then fetch needed branch to the "project A", like

git fetch <Partial repo path> refs/heads/master:refs/new_revs/trunk

and then manually merge the changes in the project A repository.