Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Update git-svn git mirror without redownloading everything

I made a git mirror of a svn repository using

    git svn clone svn://svn.svnrepo.com

I uploaded it to github and was able to update the local repo using

    git svn rebase svn://svn.svnrepo.com

and push the updates to github

Later after I had deleted the local copy I wanted to update the remote again

So I cloned the git repo

    git clone git://git.gitrepo.com

But when I tried to rebase I got an error

    git svn rebase svn://svn.svnrepo.com

    Data from a previous version of git-svn exists, but

    (required for this version (1.8.3.2) of git-svn) does not exist.

    Done migrating from a git-svn v1 layout

then it gives an Unable to determine upstream SVN information from HEAD history error

Ive tried:

    git svn init svn://svn.svnrepo.com

with:

    git svn fetch

but that starts a re-download of the entire svn repo which takes over 24 hours The current svn revision is marked by the git-svn-id in the commit log and seems fine, how do I stop git svn fetch from re-fetching files that already exist or rebase it without an entire re-download? This mirror never had commits that would make it different from the svn upstream.

like image 312
jhilliar Avatar asked Nov 21 '13 09:11

jhilliar


People also ask

How do I migrate an SVN repository with history to a new Git repository?

Prepare a migration environment. Convert the source SVN repository to a local Git repository. (Optional) Synchronize the local Git repository with any changes from SVN repository while developers continue using SVN. Push the local Git repository to a remote Git repository hosted on Azure Repos.

Can I use Git and SVN at the same time?

git works perfectly fine with a svn repository on the other side, why not benefit from that? Certainly possible, and a fair move towards your colleagues, not to push unfinished changes. however there is one huge danger hidden in there: you will tend to make very few commits to the companies repository.

What is the equivalent of SVN update in Git?

Getting the latest changes from SVN The equivalent to git pull is the command git svn rebase . This retrieves all the changes from the SVN repository and applies them on top of your local commits in your current branch.

How do I clone a SVN repository?

# Clone a repo with standard SVN directory layout (like git clone): git svn clone http://svn.example.com/project --stdlayout --prefix svn/ # Or, if the repo uses a non-standard directory layout: git svn clone http://svn.example.com/project -T tr -b branch -t tag --prefix svn/ # View all branches and tags you have ...


1 Answers

just need to run the following commands

git config svn-remote.svn.url $SVN_URL
git config svn-remote.svn.fetch :refs/remotes/git-svn
svn2git --rebase

or you can also manually edit .git/config to add the svn-remote section:

[svn-remote "svn"]
    url = SVN_URL
    fetch = :refs/remotes/git-svn

and from now on just svn2git --rebase

--

PS: credit to my sources:

  • http://blog.tfnico.com/2010/08/syncing-your-git-repo-with-subversion.html
  • How can I reconnect a git repository with a svn repository?
like image 138
arhak Avatar answered Sep 18 '22 14:09

arhak