gpt4 book ai didi

git - 在 git 中,提交和修订之间有什么区别

转载 作者:IT王子 更新时间:2023-10-29 00:43:35 25 4
gpt4 key购买 nike

有很多git命令,比如git clone --depth 10 <repo> , 需要修改次数 [ git help revisions ] 给予。

提交和修订之间有什么区别(在 git 中,rather than say svn)?

或者它是否仅在尝试计算修订/提交时以复数形式出现,例如必须通过遍历提交及其父项的 DAG(有向无环图)或其他一些仔细区分来计算修订?

最佳答案

参见 SPECIFYING REVISIONS 的“git rev-parse ” :

A revision parameter <rev> typically, but not necessarily, names a commit object.
It uses what is called an extended SHA1 syntax, [and includes] various ways to spell object names.

所以“修订版”指的是您可以用作参数的 id,引用 git 中的对象(通常是提交)。

HEAD@{5 minutes ago}是引用 5 分钟前提交的修订。

gitrevision 提及:

[...] some Git commands (such as git show) also take revision parameters which denote other objects than commits, e.g. blobs ("files") or trees ("directories of files").

例如,以下 rev 参数不引用提交:

<rev>:<path>, e.g. HEAD:README, :README, master:./README

A suffix : followed by a path names the blob or tree at the given path in the tree-ish object named by the part before the colon.


Git 中的“提交”通常表示一个“提交对象”(如 git commit-tree 中所述):

A commit encapsulates:

  • all parent object ids
  • author name, email and date
  • committer name and email and the commit time.

所以:

  • 提交指定 一个 git 对象(其他是 blob、树、标签、注释),
  • 修订是一种引用 git 对象的方式。

在你的情况下 ( git clone ) --depth <n>做:

Create a shallow clone with a history truncated to the specified number of revisions.

它适用于在该深度可访问的所有提交,直到 n DAG 中每个路径的修订。
由于结果可以超过 n提交,术语修订在这里更适应,以强调你不想要只是 n提交,但最大引用的任何提交 n可访问修订版。

但是,在这种情况下,修订显然只引用可访问的提交(如下图所示)(如您在“Is git clone --depth 1 (shallow clone) more useful than it makes out?”中提到的)。

问题是“从什么地方可达”?

您引用了 this thread其中包括:

IIRC, --depth=<n> is not "deepen by <n>", but "make sure I have at least <n> from the updated tip(s)".
The shallow-clone hack gives you quite useless (even though it may be internally consistent) semantics if you shallow-cloned way in the past and fetched with --depth after the other side added many more commits than <n>, as you cannot guess what the right value of <n> should be without actually fetching without --depth.

关于git - 在 git 中,提交和修订之间有什么区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11792538/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com