git - 有没有办法克隆 git 存储库(包括其远程存储库)?

标签 git git-svn git-clone git-remote

有没有办法使用某种git克隆/获取机制来使我的克隆中的存储库保持最新,包括来自远程的所有refs/remotes/

这与 git fetch --all 、 git pull --all 或 git svn 无关。这只是将 Remote 的 Remote 复制到克隆。

像这样的命令会很棒:

git clone --include-remote-remotes git@linuxmachine:TheGitSvnClone

然后定期

git fetch --update-remote-remotes origin

一些细节:

远程有自己的名为svn的远程,其中包含一些分支:

  • refs/heads/master
  • 引用/远程/svn/trunk
  • 引用/remotes/svn/branch1
  • 引用/remotes/svn/branch2

作为克隆的结果,我期望一个正常的 git 存储库,包括工作副本( checkout 文件)和以下引用:

  • refs/heads/master
  • (refs/remotes/origin/master)
  • 引用/远程/svn/trunk
  • 引用/remotes/svn/branch1
  • 引用/remotes/svn/branch2

我无法使用git clone --mirror,因为这会创建一个裸存储库。

为什么这么复杂?

我们公司目前使用的是svn。同时我正在准备从 svn 到 git 的迁移。

不幸的是,git svn fetch在我的Windows机器上需要很长时间,所以我使用一台Linux机器定期执行git svn fetch,然后复制生成的git repo使用 FileZilla。

最佳答案

正常克隆存储库后,指示 Git 获取远程引用:

git config --add remote.origin.fetch '+refs/remotes/svn/*:refs/remotes/svn/*'

后续的 git fetch 调用将下载 svn 引用。

关于git - 有没有办法克隆 git 存储库(包括其远程存储库)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42347647/

相关文章:

javascript - 缺少一些试图将 Bootstrap 作为本地 git 子模块包含到 meteor 中的东西

svn - git-svn:从非主分支恢复提交

git - 如何避免在克隆时提供 git repo 的绝对路径?

git - git remote add 和 git clone 的区别

windows - 无法创建目录 '/home/username/.ssh'

git - 在 GIT 中处理 "dead/unused"分支的最佳方法是什么?

Git pull origin/master 分支到local/master,当在local/develop

git - 将 SVN checkout 转换为使用 git (git-svn)

svn - Git svn rebase : checksum mismatch

git - 将 git 从本地机器克隆到我的服务器?