1 Git SVN Mirror Migration
Tiziano Müller edited this page 2018-10-05 13:16:01 +02:00

Until October 2nd, the Git repository on https://github.com/cp2k/cp2k was a mirror of the CP2K Subversion repository hosted at https://sourceforge.net/projects/cp2k/.

With the final migration of CP2K to Git, the mirror repository was moved to https://github.com/cp2k/cp2k-svn and a new (cleaned-up) Git repository took its place at https://github.com/cp2k/cp2k.

This document is for people who had a fork of the old Git-SVN mirror and need to migrate their commit history to the new repository.

Moving your fork

If you have a fork of the old repository, you have to fork again from the new repository. The easiest way is to remove or rename your old fork, and re-create it from scratch.

Moving commits

If you do not care about the history of your changes and you have only a small number of commits, the easiest way is to simply copy the changed files from a checkout of your old repository to the new one and re-commit them.

If you have some commits on your old fork you would like to move over to the new official Git repository - preserving their history -, you have to export them as patches and import them on the new fork of the Git repository.

Assuming you have a clone of your fork, first make sure that:

  • you are in the top-directory of your clone (where the .git directory is)
  • you have a remote upstream configured which points to https://github.com/cp2k/cp2k-svn
  • this remote is up-to-date
  • and that the current Git working directory does not contain uncommitted changes

In detail:

$ cd work/old-cp2k-clone  # your repository
$ git remote add upstream git@github.com:cp2k/cp2k-svn.git
[...]
$ git fetch --all  # get all commits from the old repo
[...]
$ git status --untracked-files=no
On branch master
Your branch is ahead of 'origin/master' by 256 commits.
  (use "git push" to publish your local commits)

nothing to commit (use -u to show untracked files)

Since the patches will be re-applied on top of all the current commits, the best way is to rebase your changes in the current repository on the latest development.

See https://git-scm.com/book/en/v2/Git-Branching-Rebasing for more information about the rebasing process.

Again, the commands are:

$ git rebase upstream/master  # add -i to also squash/edit/drop your commits in the same process

Remember, you can always abort the rebasing and return to your previous state (with Git >= 1.8):

$ git rebase --abort

Afterwards, you can simply export the commits including their messages and authors to patches:

$ mkdir ../cp2k-patches
$ git format-patch --relative=cp2k -o ../cp2k-patches upstream/master

Now change to the directory of your clone of the new Git repository and re-apply the patches as commits there:

$ cd ../new-cp2k-clone
$ git am ../cp2k-patches/*

There may again be some conflicts which you have to resolve.