在git中,commit(s)和revision(s)之间有什么区别? [英] In git, what is the difference between a commit(s) and a revision(s)

查看:1426
本文介绍了在git中,commit(s)和revision(s)之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有许多git命令,例如 git clone --depth 10< repo> ,它们需要修改的数量[ git help revisions ]给出。

提交和修订之间的区别是什么(在git中,)?



/提交,例如那么修改必须通过行动提交和他们的父母的DAG(有向无环图)或其他一些细致的区别来计算? >请参阅指定修订 //git-scm.com/docs/git-rev-parserel =nofollow noreferrer> git rev-parse :


修订参数< rev> 通常(但不一定)命名提交对象。

它使用所谓的扩展SHA1语法,[并且包括]拼写对象名称的各种方法。


因此,修订版是指您可以用作参数的参数参考 git中的对象(通常是提交)。
$ b

HEAD @ {5分钟前} 是一个修订版,引用了commit present 5分钟前。



gitrevision 提及:


一些Git命令(例如< a gref show/ code)也是取表示除提交之外的其他对象的修订参数,例如 blob (文件)或(文件目录)。


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

 < rev>:<路径> ;,例如HEAD:README,:README,master:./自述文件




后缀后面跟着一个路径,指出冒号前面部分命名的tree-ish对象中给定路径的blob或tree。







Git中的commit通常指定一个commit object a href =http://git-scm.com/docs/git-commit-tree =nofollow noreferrer> git commit-tree
$ b


一个提交封装:


  • 所有父对象id

  • 作者姓名,电子邮件和日期

  • 提交者姓名和电子邮件以及提交时间。 b






所以:


  • 一个提交指定了一个的git对象(其他的是blob,tree,tags,notes),
  • 一种引用git对象的方法。




    您的情况( git clone - depth< n> 确实:

    < blockquote>

    创建一个历史截断为指定数量的修订的浅层克隆。


    对于所有可以在该深度访问的提交,高达 n DAG中的每个路径的修订版本。

    由于结果可能超过 n 提交,所以术语版本更适合于强调您't只需要 n 提交,但任何提交都可以访问最多 n 修订版。



    但是,在这种情况下,修订明确地仅引用提交(如下图所示)可达(正如您在 git clone -depth 1 (浅层克隆)比它更有用吗?)。



    问题是从哪里可以到达?

    您引用了这个线程,其中包括:


    IIRC, - depth =< n> code>不是深化< n> ,而是确保我至少有< n> 来自更新后的提示

    浅层克隆hack让你无用(即使它可能内部一致)语义,克隆方式,并在另一方添加了比< n> 更多的提交之后,< - 深度
    ,因为如果没有 - depth ,您无法猜测< n> 的正确
    值应该实际取得$ c>。



    There are a number of git commands, such as git clone --depth 10 <repo>, that require the number of revisions [git help revisions] to be given.

    What is the distinction between a commit and a revision (in git, rather than say svn)?

    Or does it only show up in the plural when trying to count revisions/commits, e.g. that revisons must be counted by walking the DAG (directed acyclic graph) of commits and their parents, or some other careful distinction?

    解决方案

    See "SPECIFYING REVISIONS" of 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.

    So "revision" refers to the id you can use as a parameter to reference an object in git (usually a commit).

    HEAD@{5 minutes ago} is a revision which reference the commit present 5 minutes ago.

    gitrevision mentions:

    [...] 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").

    For instance, the following rev parameter doesn't reference a commit:

    <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.


    A "commit" in Git generally designates a "commit object" (as described in git commit-tree for instance):

    A commit encapsulates:

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


    So:

    • a commit designates one of the git objects (others are blobs, tree, tags, notes),
    • a revision is a way to reference a git object.

    In your case (git clone) --depth <n> does:

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

    It is for all the commits accessible at that depth, up to n revisions per path in the DAG.
    Since the result can be more than n commits, the term revision is more adapted here in order to emphasize you don't want just n commits, but any commits referenced by a max of n revisions accessible.

    However, in this context, revisions clearly reference only commits (as illustrated below) reachable (as you mentioned in "Is git clone --depth 1 (shallow clone) more useful than it makes out?").

    The question is "reachable from what"?

    You referenced this thread which included:

    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中,commit(s)和revision(s)之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆