什么是“斑点"?在Github中对应吗? [英] What does "blob" in Github correspond to?

查看:49
本文介绍了什么是“斑点"?在Github中对应吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下URL中"blob"后面的单词指向给定存储库的"master"分支:

The word following "blob" in below URL points to the "master" branch of given repository:

https://github.com/celery/celery/blob/master/docs/django/first-steps-with-django.rst

根据上述约定,以下URL指向什么?

As per the above convention, what does the following URL point to?

https://github.com/celery/celery/blob/241d2e8ca85a87a2a6d01380d56eb230310868e3/docs/django/first-steps-with-django.rst

我正在阅读最新芹菜的文档,想在Github上查看其来源,因此出现了问题.请注意,我可以查看 master 文档,请转到"master"分支.

I was reading the latest documentation of celery and wanted to see its source on Github, thus the question. Please note that I can view the source code of master documentation by going to "master" branch.

推荐答案

这实际上是关于 GitHub 的问题,而不是关于 Git 的问题.

This is really more a question about GitHub than it is about Git.

请记住,Git本身就是有关 commits 的内容.每个提交都存储一些数据(一组文件的快照)和一些元数据,包括诸如进行提交的人,时间和原因之类的东西.这些提交中的每一个都由其哈希ID唯一标识.分支和标记名称(如果存在任何这样的名称),仅用于查找某些特定哈希ID,以使您(或Git)可以从任何提交中的元数据项之一开始的列表开始父哈希ID,这样Git可以从 last 提交开始并向后工作.

Remember, Git itself is all about commits. Each commit stores some data—a snapshot of a set of files—and some metadata, including stuff like who made the commit, when, and why. Each of these commits is uniquely identified by its hash ID. Branch and tag names, if any such names exist, merely serve to find some particular hash ID to get you—or Git—started as one of the metadata items in any commit is a list of parent hash IDs, so that Git can start at the last commit and work backwards.

使用存储的数据和元数据提交是Git存在的原因.每个Git存储库都是提交的集合,外加一些辅助数据以帮助查找提交.(您的计算机上的非裸露存储库还为您提供了一个工作区,您可以在其中进行新工作,但提交和辅助数据是您在该工作区中进行的,不要让你在这里做新工作,这是最低限度的要求.)

Commits, with their stored data and metadata, are the reason Git exists. Each Git repository is a collection of commits, plus some ancillary data to help find commits. (A non-bare repository on your computer also provides you with a work-area in which you can do new work, but the commits and ancillary data, which don't let you do new work here, are the bare minimum.)

GitHub与 commits 无关.GitHub是关于共享的. 1 这种共享使用(裸露的)Git存储库,但除此之外还增加了很多东西.为此,需要Git存储库(或无论如何 2 某种存储库),但不是增值部分.

GitHub, on the other hand, is not about commits. GitHub is about sharing.1 This sharing uses (bare) Git repositories, but adds a ton more stuff on top of that. The Git repositories—or some kind of repository anyway2—are necessary to this, but are not the added-value part.

当GitHub试图增加其附加值时,他们开始添加以下内容:这是一种在一次特定提交中访问特定文件的便捷方法.您的界面 GitHub是一个API,并且该API通过HTTP/HTTPS进行编码.这意味着URL和JSON等.

As GitHub try to increase their added value, they start adding things like: Here's a convenient way to access one particular file within one particular commit. Your interface to GitHub is an API, and that API is encoded via HTTP/HTTPS. That means URLs and JSON and so on.

在这种情况下,GitHub发明了一些特殊的URL路径(请参阅 URL的剖析),可以引用提交中的文件.他们提供了一种使用提交哈希ID加上提交中的文件路径来访问特定提交中的文件的方法,以及使用分支名称(例如 master )的另一种方法提交中的文件路径,用于访问由该分支名称​​ 标识的提交中的文件.

In this case, GitHub have invented some particular URL paths (see the anatomy of a URL) that can refer to a file within a commit. They have provided one way to use a commit hash ID plus a file-path-within-commit to access that file in that specific commit, and another way to use a branch name (such as master) plus a file-path-within-commit to access that file in the commit identified by that branch name.

要在Git中执行此操作,通常只需 git checkout 分支名称-将 entire commit 放入您的工作树中,然后查看 3 可以通过操作系统级别的路径获取文件,但可能是您的问题是:如何从分支名称标识的一次提交中查看一个文件?在这种情况下,请尝试 git show :

To do this in Git, you'd normally just git checkout the branch name—which puts the entire commit into your work-tree—and then look at the file by its OS-level path, which is derived from its in-Git-commit path.3 But perhaps your question is: How can I view one file from one commit identified by branch name? In which case, try git show:

git show master:path/to/File.ext

将允许您查看该提交中以该名称( path/to/file.ext )存储的文件(名称 master 解析为的任何哈希ID).

will let you view the file stored under that name (path/to/file.ext) from that commit (whatever hash ID the name master resolves to).

1 共享和归档(异地存储).二!我们的两个主要武器是...

1Sharing and and archival (off-site storage). Two! Our two principle weapons are...

2 请记住,Bitbucket曾经是Mercurial存储库共享站点.它持有汞回购,而不是Git回购.也许有一天GitHub将拥有其他类型的存储库.

2Remember that Bitbucket was once a Mercurial repository sharing site. It held Hg repos, not Git repos. Perhaps someday GitHub will hold some other kind of repository.

3 OS级别的路径可能与Git内的路径有所不同.例如,在典型的Windows系统上,文件名大小写(大写或小写)仅被尊重一半,因此名为 path/to/File.ext 的Git文件可能驻留在Windows OS文件系统中在 path/TO/file.EXT 下.典型的MacOS文件系统对UTF-8字符串强制执行某些分解规则,因此MacOS也可能会更改Git文件的路径.Linux倾向于不解释UTF-8,因此,如果Git使用无效的UTF-8字节序列作为文件路径名,则Linux根本没有问题.

3The OS-level path might differ from the in-Git path in several ways. For instance, on a typical Windows system, filename case (upper or lower case) is only half-respected, so a Git file named path/to/File.ext might reside in a Windows OS file system under path/TO/file.EXT. A typical MacOS file system enforces certain decomposition rules on UTF-8 strings, so MacOS might change a Git file's path as well. Linux tends not to interpret UTF-8, so if Git uses an invalid UTF-8 byte-sequence as a file path name, Linux has no issues at all here.

这篇关于什么是“斑点"?在Github中对应吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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