Emmanuel Caradec
Emmanuel Caradec

Reputation: 2287

Is there a way to "git svn dcommit" from a cloned git-svn repository :

Is there a way to "git svn dcommit" from a cloned git-svn repository :

I have several branches in my svn, sometimes it is very small branch and it is nice to have it in the same directory, but sometimes these branches grow big and it is nice to move the whole thing to another folder.

But when I do a git clone from this local repository to another place on my disk git-svn lost all its information and I don't known how to connect it back. I suppose I could just make a copy of the folder, but doing it through git would be nicer.

Upvotes: 9

Views: 1793

Answers (5)

idbrii
idbrii

Reputation: 11916

I got this working! This is my elaboration on @Brian Campbell's answer but I also include how I initially setup my checkouts to make differences from your setup more clear.

On one computer, fetch all history and push it to a (pre-configured) git remote.

:: This init command must be the same on all machines
git svn init --trunk=https://[email protected]/svn/proj https://[email protected]/svn/proj proj
cd proj
git remote add mine https://git.us.ca/idbrii/proj.git

:: Get history the beginning of this project.
git svn fetch -r 306842:HEAD

git push --set-upstream mine main

To connect any other computer: use the same init, fetch a tiny bit of history, fetch git history, and then splice them together.

If your git remote name isn't mine or your svn setup is different, the remote and ref names might differ.

git svn init --trunk=https://[email protected]/svn/proj https://[email protected]/svn/proj proj
cd proj
git remote add mine https://git.us.ca/idbrii/proj.git

:: Only fetch a bit of history. This is enough to configure git-svn but doesn't
:: take too long. *Don't* fetch HEAD so svn rebase actually does something.
git svn fetch -r 560851:575104
git fetch mine
git reset --hard mine/main
:: Verify the remote name is correct before proceeding. If not, look around inside remotes.
dir .git\refs\remotes\origin\trunk
git update-ref refs/remotes/origin/trunk main
git svn rebase

The last command should end with output like this:

Partial-rebuilding .git/svn/refs/remotes/origin/trunk/.rev_map.a8370998-ac15-0410-90df-bdb97e9fde4a ...
Currently at 575104 = 5978493cb8514a8517er552480da4e799d96cb317a795a4
r306842 = 5813acf515009930838f199cfbf6356ee670a245
...
r552484 = b765e78c3a7ad4cd5fb9946623ea763dfdef4574
r552488 = 67b823895920ccbc3ce256099c6065d17e1a2728
r560851 = 83350d598bf94c1f5c49fd22e99c8d3dd80604d5
r575104 = 25cb9009d5b666d1df668069cb993f3beb2f60b2
r575209 = 10ef809b5073fa3a799b98671c499199c1851c95
r575300 = 15164c67df7c22da03e4f4564a76994852a9f608
Done rebuilding .git/svn/refs/remotes/origin/trunk/.rev_map.a8370998-ac15-0410-90df-bdb97e9fde4a
Successfully rebased and updated refs/heads/main.

That goes really fast so it seems to be just verifying we have the correct data and not re-downloading the commit data.

Upvotes: 0

Brian Campbell
Brian Campbell

Reputation: 332846

Once you've cloned a git-svn repo, you can pull in the information you need by running git svn init with the same parameters as the original repo was created with. According to the WebKit git-svn instructions, the trick is to use update-ref to get yourself to a state where you can fast-forward to the tip of the SVN tree:

git svn init -T trunk http://svn.webkit.org/repository/webkit
git update-ref refs/remotes/trunk origin/master

The exact parameters passed to git svn init depend on the setup of your Subversion repo and git-svn clone.

Upvotes: 14

David Cournapeau
David Cournapeau

Reputation: 80710

It is possible, but you have to set things up a bit differently. Here is how we do it on numpy - the repo was created with git-svn-automirror

You can look at the function _git_update_mirror to see how to do it manually

Upvotes: 1

davetron5000
davetron5000

Reputation: 24841

The svn info is not much more than a few bits of info in the .git/config file, right? You could just hand-jam those and be good to go.

Upvotes: -1

mipadi
mipadi

Reputation: 410662

Unfortunately not, as git-clone does not clone the git-svn information when performing a clone. You can read more about the situation here.

Upvotes: 3

Related Questions