Question

I already have a svn read only repo checked out (svn co and not git svn). I have made some changes and commits using git which is then pushed up to github.

At this point, git does not have all of the history from svn. I was wondering if there was a way to extract and import this at this point.

The various git-svn guides show how to import a clean repo and transfer the history but not one that I can find that is already in use.

Was it helpful?

Solution

You will probably have to do an svn import into a fresh git repository, merge the two repositories (just add them together, it will probably complain about them being unrelated) and then rebase the changes you made unto the imported history.

OTHER TIPS

To complete Thilo's good answer, once you have imported the svn repo into a git one, you can add that git repository into yours with a script as detailed in merging in unrelated git branches

#!/bin/bash

set -e

if test -z "$2" -o -n "$3"; then
    echo "usage: $0 REPO BRANCHNAME" >&2
    exit 1
fi

repo=$1
branch=$2

git fetch "$repo" "$branch"

head=$(git rev-parse HEAD)
fetched=$(git rev-parse FETCH_HEAD)
headref=$(git rev-parse --symbolic-full-name HEAD)

git checkout $fetched .

tree=$(git write-tree)

newhead=$(echo "merged in branch '$branch' from $repo" | git commit-tree $tree -p $head -p $fetched)
git-update-ref $headref $newhead $head
git reset --hard $headref

Other methods includes:

  • try a "simple" git pull REPO BRANCH
  • using git grafts to restore svn merge history by creating a text file at .git/info/grafts, where each line contains a commit id followed by its parents. Your local repository will henceforth act as if that commit actually descended from both parents.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top