目录 搜索
Guides gitattributes giteveryday gitglossary gitignore gitmodules gitrevisions gittutorial gitworkflows Administration git archive git bundle git clean git filter-branch git fsck git gc git instaweb git reflog Basic Snapshotting git add git commit git diff git mv git reset git rm git status Branching and Merging git branch git checkout git log git merge git mergetool git stash git tag Debugging git bisect git blame git grep Email git am git format-patch git request-pull git send-email External Systems git fast-import git svn Getting and Creating Projects git clone git init Git git annotate git archimport git bisect-lk2009 git check-attr git check-mailmap git check-ref-format git checkout-index git cherry git citool git column git credential git credential-cache git credential-store git cvsexportcommit git cvsimport git cvsserver git diff-files git diff-tree git difftool git fast-export git fetch-pack git fmt-merge-msg git get-tar-commit-id git gui git http-backend git http-fetch git http-push git imap-send git index-pack git interpret-trailers git ls-remote git ls-tree git mailinfo git mailsplit git merge-file git merge-index git merge-one-file git merge-tree git mktag git mktree git name-rev git notes git p4 git pack-objects git pack-redundant git pack-refs git parse-remote git patch-id git prune git prune-packed git quiltimport git receive-pack git remote-ext git remote-fd git remote-testgit git repack git replace git rerere git send-pack git sh-i18n git sh-setup git shell git show-branch git show-index git stripspace git unpack-file git unpack-objects git upload-archive git upload-pack git var git verify-commit git verify-tag git whatchanged git worktree Inspection and Comparison git describe git shortlog git show Miscellaneous api credentials api index gitcli gitcore tutorial gitcredentials gitcvs migration gitdiffcore githooks gitk gitnamespaces gitremote helpers gitrepository layout gitsubmodules gittutorial 2 gitweb gitweb.conf pack format User Manual Patching git apply git cherry-pick git rebase git revert Plumbing Commands git cat-file git check-ignore git commit-tree git count-objects git diff-index git for-each-ref git hash-object git ls-files git merge-base git read-tree git rev-list git rev-parse git show-ref git symbolic-ref git update-index git update-ref git verify-pack git write-tree Server Admin git daemon git update-server-info Setup and Config git git config git help Sharing and Updating Projects git fetch git pull git push git remote git submodule
文字

命名

git-bundle  - 通过归档移动对象和引用

概要

git bundle create <file> <git-rev-list-args>git bundle verify <file>git bundle list-heads <file> [<refname>…]git bundle unbundle <file> [<refname>…]

描述

有些工作流要求一台机器上的一个或多个开发分支在另一台机器上复制,但这两台机器不能直接连接,因此不能使用交互式Git协议(git,ssh,http)。该命令提供了一种用于支撑git fetchgit pull通过在始发机器包装在归档对象和引用,然后导入到那些使用另一存储库来操作git fetchgit pull通过某种手段移动存档(例如,通过sneakernet)之后。由于存储库之间不存在直接连接,因此用户必须为目标存储库持有的数据包指定基础:数据包假定基础中的所有对象都已存在于目标存储库中。

选项

create <file>

用于创建名为file的包。这需要git-rev-list-args参数来定义包内容。

verify <file>

用于检查捆绑文件是否有效,并将干净地应用于当前存储库。这包括对捆绑格式本身的检查以及检查先决条件提交是否存在并且在当前存储库中完全链接。git bundle打印缺少提交列表(如果有),并以非零状态退出。

list-heads <file>

列出软件包中定义的引用。如果后面跟随一个引用列表,则只会打印出与给定值相匹配的引用。

unbundle <file>

传递包中的对象以git index-pack存储在存储库中,然后打印所有定义的引用的名称。如果给出了参考文献列表,则只列出与列表中相匹配的参考文献。这个命令真的很管用,打算只能被调用git fetch

<git-rev-list-args>

一列的参数,接受列表git rev-parsegit rev-list(和包含命名ref时,请参阅指定下面的参考文献),它指定的特定对象和引用运输。例如,master~10..master导致当前主引用与自第10个祖先提交后添加的所有对象一起打包。对可能打包的引用和对象的数量没有明确的限制。

<refname>…

用于限制报告的参考文献的列表。这主要是为了使用git fetch,它只希望接收那些被请求的引用,而不一定是包中的所有内容(在这种情况下,git bundle就像git fetch-pack)。

指定参考

git bundle将只打包显示的引用git show-ref:这包括头部,标签和远程头部。诸如master~1不能打包的参考文献,但完全适合于定义基础。可以打包多个参考,并且可以指定多个参考。包装的物品是那些没有包含在给定基地联盟中的物品。每个基可以明确指定(例如^master~10),或隐式地(例如master~10..master--since=10.days.ago master)。

目的地所使用的基础是非常重要的。在谨慎的方面犯错是可以的,导致包文件包含已经在目标中的对象,因为在目的地解包时忽略这些对象。

例子

假设您希望将历史记录从计算机A上的存储库R1传输到计算机B上的另一个存储库R2中。出于任何原因,A和B之间的直接连接不被允许,但我们可以通过某种机制将数据从A移动到B(CD ,电子邮件等)。我们想要在R1的分支主机上进行开发时更新R2。

为了引导流程,您可以先创建一个没有任何基础的软件包。您可以使用标签来记住您上次处理的内容,以便稍后使用增量包更新其他存储库:

machineA$ cd R1
machineA$ git bundle create file.bundle master
machineA$ git tag -f lastR2bundle master

然后将file.bundle传输到目标计算机B.由于此捆绑包不需要提取任何现有对象,因此可以通过从计算机克隆来在计算机B上创建新的存储库:

machineB$ git clone -b master /home/me/tmp/file.bundle R2

这将在生成的存储库中定义一个名为“origin”的远程服务器,该服务器允许您从包中获取和拉取数据。R2中的$ GIT_DIR / config文件将包含如下所示的条目:

[remote "origin"]
    url = /home/me/tmp/file.bundle
    fetch = refs/heads/*:refs/remotes/origin/*

要更新生成的mine.git存储库,可以使用增量更新替换存储在/home/me/tmp/file.bundle中的包后进行读取或拉取。

在原始存储库中完成更多工作后,可以创建增量包来更新其他存储库:

machineA$ cd R1
machineA$ git bundle create file.bundle lastR2bundle..master
machineA$ git tag -f lastR2bundle master

然后您将该软件包转移到另一台机器以替换/home/me/tmp/file.bundle,并从中取出。

machineB$ cd R2
machineB$ git pull

如果您知道预期的收件人存储库应提供哪些必要的对象,则可以使用该知识来指定基准,并提供一个截止点来限制生成的捆绑包中的修订和对象。前面的例子为此使用了lastR2bundle标签,但您可以使用任何其他选项,您可以将它们提供给git-log [1]命令。这里有更多的例子:

您可以使用以下两种标签:

$ git bundle create mybundle v1.0.0..master

你可以使用基于时间的基础:

$ git bundle create mybundle --since=10.days master

您可以使用提交的数量:

$ git bundle create mybundle -10 master

您可以运行git-bundle verify以查看是否可以从以基础创建的包中提取:

$ git bundle verify mybundle

这将列出你必须提交什么提交,如果你没有提交,就会出错。

从收件人存储库的角度来看,捆绑包就像它从中提取或从中取出的常规存储库。例如,您可以在提取时映射引用:

$ git fetch mybundle master:localRef

你也可以看到它提供的参考资料:

$ git ls-remote mybundle
上一篇: 下一篇: