Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In GitHub URL's: what is the difference between a tree and a blob?

I keep noticing this whenever I'm trying to add links to github files. You can add a link using blob:

https://github.com/facebook/pop/blob/master/Podfile

And the same doc comes up if you change blob to tree:

https://github.com/facebook/pop/tree/master/Podfile

What is the difference? Whenever I want to add a link for posterity in a doc, which one should I prefer?

like image 375
gran_profaci Avatar asked Sep 08 '16 22:09

gran_profaci


People also ask

What is a blob 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 a tree GitHub?

A Git tree object creates the hierarchy between files in a Git repository. You can use the Git tree object to create the relationship between directories and the files they contain. These endpoints allow you to read and write tree objects to your Git database on GitHub.

What is the difference between a tree and commit?

A commit object is an object that references a tree and associates other metadata (author, committer, timestamps, etc) with it. Multiple commit objects can reference the same tree (if the state of files in each commit is identical).

What is a tree in URL?

A URL tree is a hierarchical container class that is well suited for storing information about a URL hierarchy. The root of a URL tree is the hostname part of the URL, for example www.w3.org:8000 .


1 Answers

GitHub's website currently seems to be:

  • Using blob for files, and tree for directories, in URLs;
  • Redirecting browsers which request file URLs containing tree to contain blob instead; and
  • Redirecting browsers which request directory URLs containing blob to URLs containing tree instead.

It's possible that GitHub's website, at the time you asked the question, was only rewriting file URLs between tree and blob, instead of properly redirecting them. (Rewriting and redirecting URLs are activities of web servers.) If so, then the change wouldn't appear in your browser's address bar. But maybe you didn't mean that.

like image 183
MarkDBlackwell Avatar answered Sep 23 '22 16:09

MarkDBlackwell