更新时间:2021-11-23 22:33:26
不是从包中克隆,而是使用通配符refspec创建一个新的存储库并获取。我已经在示例中添加了第二个分支特性
和一个标记 v1.0
,以使其更具说明性: p>
Instead of cloning from the bundle, create a new repository and fetch using a wildcard refspec. I have added a second branch feature
and a tag v1.0
to the example to make this more illustrative:
$ mkdir there
$ git init .
$ git fetch --update-head-ok ../here/myrepo.bundle '*:*'
Receiving objects: 100% (5/5), done.
From ../here/myrepo.bundle
* [new tag] v1.0 -> v1.0
* [new branch] master -> master
* [new branch] feature -> feature
$ git checkout
*:*
refspec会将所有远程引用读取到同名的本地引用中,如果它们不存在则创建它们。 - update-head-ok
参数是必需的,因为 git init
会创建一个 master
The *:*
refspec will fetch all remote refs into equally named local refs, creating them if they don't exist. The --update-head-ok
argument is needed since git init
will create a master
branch which is likely also present in the remote.
由于这是一个带有直接URL的提取,因此根本不需要遥控器。请注意,这对于任何类型的源repo URL都是一样的,而不仅仅是捆绑。
Since this is a fetch with a direct URL, no remotes are needed at all. Note that this would work equally for any kind of source repo URL, not just for bundles.
新旧版本库的参考文献的平等可以通过比较来检查这两个存储库中的 git show-ref
的输出,它们应该是相同的。
The equality of the refs of the old and new repository can be checked by comparing the output of git show-ref
in both repositories, they should be identical.