tags:

views:

36

answers:

2

I've fetched a whole repository from SVN up through revision 15000. I realized that I had an extra branch stashed away in a different location. Is there any way to update the .git/config file with the location of this new branch and re-fetch only the revisions pertaining to that branch?

A: 

Assuming this is just another place in the same repository, you can simply specify through the --branch parameter. It will ignore anything that was fetched already.

If it's another SVN repository, you can set up another SVN remote and fetch from there.

Hope this helps,

Adam

adymitruk
Right, but will it consider past revisions (*before* 15000) when invoking git svn fetch? This is an older branch.
Bradley
`--branches` is only used for the initial clone/init command.
jamessan
A: 

You can add another branches entry to the svn-remote section of your .git/config file. After that, running git svn fetch should pull down the extra revisions.


If I understand correctly, you can force git-svn to rescan older revisions of branches by removing (or changing) the max-branchesRev line from .git/svn/.metadata and running git svn fetch again. If you change the line instead of removing it, then you'll want to set it to a revision earlier than when your branch was created. It'll then re-scan the branches for all revisions after that.


I probably should've gone with git svn reset first instead of messing with .git/svn/.metadata. If the following doesn't work, then I'm out of ideas. :)

# Find the svn revision git knows about that's just previous (or close to)
# the revision which created the branch
$ git svn reset -r $foundSvnRev
$ git svn fetch
$ git reset --hard $remoteBranch

Then you should be able to use git svn as per normal.

jamessan
This worked but only pulled the revisions *after* the 15000 I'd already fetched. It didn't crawl the previously fetched revisions for commits to that branch.
Bradley
I tried setting the max-branchesRev line in the .git/svn/.metadata file back to the revision just before the branch was created. Then I re-fetched with git svn fetch. Unfortunately, when I check out the branch, the only reivision I see is that one *after* the 15000 that I initially fetched and that I fetched after changing the .git/config file.Do I need to run git svn rebase in the branch or something? Can I just delete the remote branch, set the property again and re-fetch?
Bradley
You could try a `git svn rebase`, but I don't think that will work.
jamessan
What about `git svn reset` back to the revision before the branch was committed?
Bradley
Yeah, that's what I describe in the last update to my answer.
jamessan
Hmm, now my master branch only shows a single commit - the latest one to that remote branch. But the remote branch still doesn't have all the earlier commits. Going to just do a re-import.
Bradley
With git-svn I've nearly always have had to re-import. On top of it all, the aggressive ancestor find seems to work differently if done on a subset of revisions.
adymitruk