我们知道 git clone有三种类型,分别是默认的 non-bare, bare 和 mirror。那么这三者之间到底有什么区别?请看如下E文(懒得翻译 =_=)
The difference is that all refs are copied as-is. This means everything: remote-tracking branches, notes, refs/originals/* (backups from filter-branch). The cloned repo has it all. It's also set up so that a remote update will re-fetch everything from the origin (overwriting the copied refs). The idea is really to mirror the repository, to have a total copy, so that you could for example host your central repo in multiple places, or back it up. Think of just straight-up copying the repo, except in a much more elegant git way.
The new documentation pretty much says all this:
--mirror
Set up a mirror of the source repository. This implies --bare
. Compared to --bare
, --mirror
not only maps local branches of the source to local branches of the target, it maps all refs (including remote branches, notes etc.) and sets up a refspec configuration such that all these refs are overwritten by a git remote update
in the target repository.
My original answer also noted the differences between a bare clone and a normal (non-bare) clone - the non-bare clone sets up remote tracking branches, only creating a local branch forHEAD
, while the bare clone copies the branches directly.
Suppose origin has a few branches (master (HEAD)
, next
, pu
, and maint
), some tags (v1
,v2
, v3
), some remote branches (devA/master
, devB/master
), and some other refs (refs/foo/bar
, refs/foo/baz
, which might be notes, stashes, other devs' namespaces, who knows).
-
git clone origin-url
(non-bare): you will get all of the tags copied, a local branch master (HEAD)
tracking a remote branch origin/master
, and remote branches origin/next
,origin/pu
, and origin/maint
. The tracking branches are set up so that if you do something like git fetch origin
, they'll be fetched as you expect. Any remote branches (in the cloned remote) and other refs are completely ignored.
-
git clone --bare origin-url
: you will get all of the tags copied, local branches master (HEAD)
, next
, pu
, and maint
, no remote tracking branches. That is, all branches are copied as is, and it's set up completely independent, with no expectation of fetching again. Any remote branches (in the cloned remote) and other refs are completely ignored.
-
git clone --mirror origin-url
: every last one of those refs will be copied as-is. You'll get all the tags, local branches master (HEAD)
, next
, pu
, and maint
, remote branchesdevA/master
and devB/master
, other refs refs/foo/bar
and refs/foo/baz
. Everything is exactly as it was in the cloned remote. Remote tracking is set up so that if you run git remote update
all refs will be overwritten from origin, as if you'd just deleted the mirror and recloned it. As the docs originally said, it's a mirror. It's supposed to be a functionally identical copy, interchangeable with the original.
分享到:
相关推荐
"git clone"是Git中的一个核心命令,用于复制远程仓库到本地。在本文中,我们将深入探讨`git clone`命令以及如何获取其最新版本。 首先,让我们了解`git clone`的基本用法。当你运行`git clone <repository>`时,它...
### Git Clone与Submodule知识点详解 #### 一、Git Clone命令 `git clone` 命令用于克隆一个远程仓库到本地。当你需要获取一个项目的全部文件时,这个命令非常有用。 **基本用法:** ```bash git clone ``` **...
彻底解决Mac端git clone/push速度太慢的问题,详情请参阅文档。
"Git clone"是Git中的一个关键命令,用于复制远程仓库到本地。当你想要获取一个已存在的Git仓库副本时,可以使用`git clone`命令。例如,如果要从Gitblit服务端克隆一个仓库,命令格式通常是: ``` git clone ...
本文将深入探讨如何利用批处理脚本来实现这一目标,主要关注标题提及的"windows git 批量 clone 脚本"。我们将讨论每个文件的作用,并提供相关知识点。 首先,`clone-all.bat`是用于批量克隆Git仓库的脚本。在Git中...
然而,在处理包含大量或大文件的项目时,Git的性能可能会受到影响,甚至可能导致克隆(Clone)操作失败。为了解决这一问题,Git社区开发了一个名为Git LFS(Large File Storage)的扩展工具,专门用来管理大文件。...
使用命令操作进行关联git,而不是eda软件操作git,操作相关文件,提交更新,拉取代码,包含git分支的操作
Github仓库gitclone速度过慢解决方案.docx
总结起来,GitClone.com作为一个代码托管平台,利用Git的强大版本控制功能,促进开发者之间的协作。而HTML作为网页构建的基础,确保了网站内容的呈现和用户体验。通过深入了解这两个关键元素,我们可以更好地理解和...
git-fastclone, 关于类固醇,git clone 递归 fastclone git fastclone是类固醇的git clone --recursive 。为什么 fastclone?在特定机器上进行大量重复签出?知识库 1st Fastclone 2nd Fastc
tdriver git clone的文件,具体文件如下: git clone git://gitorious.org/tdriver/driver.git git clone git://gitorious.org/tdriver/sut_qt.git git clone git://gitorious.org/tdriver/agent_qt.git git clone ...
然而,在进行克隆操作时,可能会遇到子模块没有下载完全的情况,下面我们将详细介绍如何解决git clone时子模块没下载完全的问题。 首先,当我们在克隆一个包含子模块的项目时,需要使用递归克隆命令: ``` git ...
实现`git-clone-init`通常涉及到创建一个自定义的git钩子,如`pre-clone`或`post-clone`(尽管git本身并未提供这样的预定义钩子)。这个钩子脚本可以在克隆完成后运行,根据需要更新`~/.gitconfig`或当前仓库的`.git...
适用于svn迁移git自动化脚本,配置好参数即可
2016年12月20日在https://chromium.googlesource.com/breakpad/breakpad上用git clone下来的breakpad源码,供由于墙的原因无法获取到breakpad源码的人下载。
在Windows上为git clone和git pull构建可嵌入的git。 用法 从下载最新的重新打包的Git。 构建类型 小型的 软件包“ mini”是在Windows上运行git clone和git pull的最小程序集。 它不支持HTTPS。 但你可以取代...
标题 "compass git clone" 暗示我们正在讨论 Compass,一个基于 Sass 的样式库,以及如何使用 Git 进行克隆操作。Sass 是一种 CSS 预处理器,它允许我们使用变量、嵌套规则、混合、函数等特性来编写更高效、可维护的...
关于 git clone 下面说法正确的是
开发者边车,github打不开,github加速,git clone加速,git release下载加速,stackoverflow加速.zip