本文介绍了在同一个svn-remote中初始提取后添加git分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用git-svn来处理svn回购。我不希望整个回购,正弦包含很多遗产,其中包含二进制文件。我只跟踪一些目录。



这是我当前的 .git / config ,它工作正常。

  [core] 
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[svn-remotesvn]
url = https://svn.example.com/repository
fetch = trunk / Python:refs / remotes / trunk
branches = branches / {stage,prod,stage_with_proxy} / ucapi /:refs / remotes / *
branches = branches / {active} / Python /:refs / remotes / *

现在我想添加一个新的分支:

  branches = branches / {fuze_node} /:refs / remotes / * 

git svn fetch 新分支对git不可见。它的行为就好像该行不在配置中。






我知道这可以用新的svn-remote,但我不想走这条路。

为每个svn-remote git- svn在 .git / svn / .metadata 文件中存储最新提取的修订。它永远不会提取小于该值的修订。这就是为什么它不会获取您添加到配置中的分支; git-svn认为 fuze_node 分支已经被转换。



然而,你可以在不重新克隆整个存储库再次提供:


  1. 添加另一个svn-remote,包含您需要获取的所有分支;
  2. 删除旧的svn-remote;
  3. 运行 git svn fetch -R newer -svn-remote 从已添加的分支中获取修订。

您的配置应该如下所示:

  [core] 
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
#[svn-remotesvn]
#url = https://svn.example.com/repository
#fetch = trunk / Python:refs / remotes / trunk
#branches = branches / {stage,prod,stage_with_proxy} / ucapi /:refs / remotes / *
#branches = branches / {active} / Python /:refs / remotes / *
[svn-remotenewer-svn-remote]
url = https://svn.example.com/repository
fet ch = trunk / Python:refs / remotes / trunk
branches = branches / {stage,prod,stage_with_proxy} / ucapi /:refs / remotes / *
branches = branches / {active} / Python / refs / remotes / *
branches = branches / {fuze_node} /:refs / remotes / *





  branches = branches / { stage,prod,stage_with_proxy} / ucapi /:refs / remotes / * 

refs / remotes / * 仍应位于映射的右侧。否则,git-svn无法检测到已转换的提交,并尝试再次提取它们。






实际上还有另一种实现方式一样。虽然它涉及到一些使用内部git-svn文件的操作。

您可以将必要的分支添加到 .git / config 并更新 .git / svn / .metadata 文件,所以最新提取的修订变为0:

  [svn-remotesvn] 
reposRoot = https://svn.example.com/repository
uuid = 8a6ef855-a4ab-4527 -adea-27b4edd9acb6
branches-maxRev = 0
tags-maxRev = 0

之后 git svn fetch 将仅提取必要的版本。


I'm using git-svn to work with a svn repo. I don't want the whole repo, sine it contains a lot of legacy, with binaries in it. I'm only tracking some directories.

Here is my current .git/config, which is working fine.

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
[svn-remote "svn"]
    url = https://svn.example.com/repository
    fetch = trunk/Python:refs/remotes/trunk
    branches = branches/{stage,prod,stage_with_proxy}/ucapi/:refs/remotes/*
    branches = branches/{active}/Python/:refs/remotes/*

Now I want to add a new branch:

    branches = branches/{fuze_node}/:refs/remotes/*

but when doing git svn fetch the new branch is not visible to git. It acts as if the line is not in the config.


I know this could be done with a new svn-remote, but I would prefer not to take that road.

解决方案

For every svn-remote git-svn stores the latest fetched revision in .git/svn/.metadata file. It never fetches revisions less than that value. That's why it doesn't fetch the branch you've added to config; git-svn thinks fuze_node branch is already converted.

However you can fetch this branch without re-cloning the whole repository once again:

  1. Add another svn-remote with all the branches you need to fetch;
  2. Remove the older svn-remote;
  3. Run git svn fetch -R newer-svn-remote to fetch revisions from the added branch.

Your config should look like this:

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
# [svn-remote "svn"]
#    url = https://svn.example.com/repository
#    fetch = trunk/Python:refs/remotes/trunk
#    branches = branches/{stage,prod,stage_with_proxy}/ucapi/:refs/remotes/*
#    branches = branches/{active}/Python/:refs/remotes/*
[svn-remote "newer-svn-remote"]
    url = https://svn.example.com/repository
    fetch = trunk/Python:refs/remotes/trunk
    branches = branches/{stage,prod,stage_with_proxy}/ucapi/:refs/remotes/*
    branches = branches/{active}/Python/:refs/remotes/*
    branches = branches/{fuze_node}/:refs/remotes/*

Note that you have to specify exactly the same branches mapping as in the older svn-remote:

    branches = branches/{stage,prod,stage_with_proxy}/ucapi/:refs/remotes/*

That is, refs/remotes/* should still be on the right side of the mappings. Otherwise git-svn fails to detect already converted commits and tries to fetch them once again.


There's actually another way to achieve the same. It involves some manipulations with internal git-svn files though.

You can just add necessary branch to .git/config and update .git/svn/.metadata file, so the latest fetched revision becomes 0:

[svn-remote "svn"]
    reposRoot = https://svn.example.com/repository
    uuid = 8a6ef855-a4ab-4527-adea-27b4edd9acb6
    branches-maxRev = 0
    tags-maxRev = 0

After that git svn fetch will fetch only necessary revisions.

这篇关于在同一个svn-remote中初始提取后添加git分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 03:53