Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "blob" in Github correspond to?

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

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

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.

like image 666
Jai Sharma Avatar asked Nov 26 '19 09:11

Jai Sharma


People also ask

What does blob mean in GitHub?

A Git blob (binary large object) is the object type used to store the contents of each file in a repository. The file's SHA-1 hash is computed and stored in the blob object. These endpoints allow you to read and write blob objects to your Git database on GitHub. Blobs leverage these custom media types.

What is tree and blob in GitHub?

Essentially, a blob is just a bunch of bytes that could be anything, like a text file, image, actual source code etc. A tree is like a directory, it points to: blob objects (how a directory points to other files) other trees (how a directory can have subdirectories)

Where are Git blobs stored?

The contents of your files are stored in blobs, but those blobs are pretty featureless. They have no name, no structure — they're just “blobs”, after all. There it is!

What is the SHA in GitHub?

When you make a commit to save your work, Git creates a unique ID (a.k.a. the "SHA" or "hash") that allows you to keep record of the specific changes committed along with who made them and when. Commits usually contain a commit message which is a brief description of what changes were made.


1 Answers

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

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.

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

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.

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.

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

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


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

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.

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.

like image 188
torek Avatar answered Oct 14 '22 07:10

torek