【问题标题】:What is the Difference Between fetch and branch in the Git config fileGit配置文件中的fetch和branch有什么区别
【发布时间】:2021-09-09 04:18:34
【问题描述】:

Git 存储库的config 文件在[git-svn remotes] 下有fetchbranch 路径。配置文件甚至可以有多个fetch 行和多个branch 行。拥有fetchbranch 的原因是什么(以及两者之间的区别是什么?当我执行git svn fetch --all 时,我会在fetch 和所有其他branch 行中获得主干的更新。所以似乎没有区别。如果我只使用多个 branch 列出所有分支并且没有 any fetch 行,有什么缺点吗?

[svn-remote "messy-repo"]
    url = http://server.org/svn
    fetch = trunk/project-a:refs/remotes/project-a/trunk
    fetch = branches/demos/june-project-a-demo:refs/remotes/project-a/demos/june-demo
    branches = branches/server/*:refs/remotes/project-a/branches/*
    branches = branches/demos/2011/*:refs/remotes/project-a/2011-demos/*

【问题讨论】:

  • Git 本身完全忽略了这些; git-svn 对它们做什么取决于 git-svn。我会剪掉 git 标签。

标签: git-svn


【解决方案1】:

作为illustrated here,第一个git svn clone确实会生成一个带有fetch的cnfig。

如果在此之后您想签出其他分支,您首先需要将其添加到您的配置文件中:

[svn-remote "svn"]
  url = https://example.com/
  fetch = PROJECT/branches/somefeature:refs/remotes/trunk
       branches = PROJECT/branches/{anotherfeature}:refs/remotes/*

分支配置总是需要一个 glob。

来自git svn clone

在克隆存储库后,fetch 命令将能够在不影响工作树的情况下更新修订版

区别:

它类似于核心 Git [remote] 部分 除了 fetch 键不接受 glob 参数;但它们由 branchestags 键处理。

【讨论】:

    猜你喜欢
    • 2023-04-03
    • 2015-11-14
    • 2017-04-08
    • 2014-03-31
    • 2011-12-20
    • 2020-03-05
    • 2018-04-11
    • 2017-08-19
    相关资源
    最近更新 更多