<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Jacob Clark</title>
    <description>The latest articles on Forem by Jacob Clark (@imjacobclark).</description>
    <link>https://forem.com/imjacobclark</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3456%2F1wC-mced.jpg</url>
      <title>Forem: Jacob Clark</title>
      <link>https://forem.com/imjacobclark</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/imjacobclark"/>
    <language>en</language>
    <item>
      <title>Best practices for authentication in an oauth API flow?</title>
      <dc:creator>Jacob Clark</dc:creator>
      <pubDate>Thu, 06 Jun 2019 17:51:02 +0000</pubDate>
      <link>https://forem.com/imjacobclark/best-practices-for-authentication-in-an-oauth-api-flow-4e1k</link>
      <guid>https://forem.com/imjacobclark/best-practices-for-authentication-in-an-oauth-api-flow-4e1k</guid>
      <description>&lt;p&gt;I'm building an application that users Spotifys API OAuth for Authorisation, the access token that is ultimately recieved by my app from Spotify is stored as a HttpOnly Cookie on the client that requested my application in order to pass to subsequent API requests. &lt;/p&gt;

&lt;p&gt;What are best practices for ensuring authentication when working with APIs in this way? E.g the user is who they say they are on subsequent requests.  &lt;/p&gt;

</description>
      <category>help</category>
    </item>
    <item>
      <title>recomendation algorithms: how can you recommend songs based on a user's past listening history?</title>
      <dc:creator>Jacob Clark</dc:creator>
      <pubDate>Sat, 01 Jun 2019 12:31:45 +0000</pubDate>
      <link>https://forem.com/imjacobclark/recomendation-algorithms-how-can-you-recommend-songs-based-on-a-user-s-past-listening-history-224a</link>
      <guid>https://forem.com/imjacobclark/recomendation-algorithms-how-can-you-recommend-songs-based-on-a-user-s-past-listening-history-224a</guid>
      <description>&lt;p&gt;I'm interested in getting a user's past listening history from Spotify and being able to suggest songs from the Charts that a user may be interested in listening too. &lt;/p&gt;

&lt;p&gt;It's clear that you could use Genre to support this type of algorithm, the more times a user listenes to a genere, it has a higher likelihood of being suggested from the Charts. &lt;/p&gt;

&lt;p&gt;I'd like to focus on the activity of a single user and not necessarily other users using the system (content based filtering)&lt;/p&gt;

&lt;p&gt;How can this be done in practice? Anybody have any examples of algorithms or tutorials anywhere? &lt;/p&gt;

</description>
      <category>help</category>
    </item>
    <item>
      <title>A quick look at the git object store</title>
      <dc:creator>Jacob Clark</dc:creator>
      <pubDate>Fri, 13 Apr 2018 08:15:03 +0000</pubDate>
      <link>https://forem.com/imjacobclark/a-quick-look-at-the-git-object-store-290j</link>
      <guid>https://forem.com/imjacobclark/a-quick-look-at-the-git-object-store-290j</guid>
      <description>

&lt;p&gt;Let's talk about some of the internals of git and how it stores and tracks objects within the &lt;code&gt;.git&lt;/code&gt; directory. &lt;/p&gt;

&lt;p&gt;If you're unaware of what the &lt;code&gt;.git&lt;/code&gt; directory is, it's simply a space that git uses to store your repositories data, the directory is created when you run &lt;code&gt;git init&lt;/code&gt;. Information such as binary objects and plain text files for commits and commit data, remote server information and information about branch locations are stored within.&lt;/p&gt;

&lt;p&gt;The key concept throughout this entire article is very simple - pretty much every operation you do in git creates objects with a bunch of metadata which point to some more objects with a bunch of metadata and so on so for forth. That's pretty much it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Git Plumbing
&lt;/h3&gt;

&lt;p&gt;First, create a new directory and initialise it as a new git project.&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;git &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;cd &lt;/span&gt;git
&lt;span class="nv"&gt;$ &lt;/span&gt;git init
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;We can now take a look at the &lt;code&gt;.git&lt;/code&gt; directory and the contents within it.&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ tree .git
.git
|___branches
|___config
|___description
___HEAD
|___hooks
| |___applypatch-msg.sample
| |___commit-msg.sample
| |___post-update.sample
| |___pre-applypatch.sample
| |___pre-commit.sample
| |___pre-push.sample
| |___pre-rebase.sample
| |___prepare-commit-msg.sample
| |___update.sample
|___info
| |___exclude
|___objects
| |___info
| |___pack
|___refs
| |___heads
| |___tags
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;For the moment most of the directories git created are empty. This is because we haven't begun tracking any files or directories yet.&lt;/p&gt;

&lt;p&gt;Under the hood git is nothing more than a key-value store, it takes a file and compresses it and then stores it against its computed SHA1 as a binary object.&lt;/p&gt;

&lt;p&gt;Git has a low level plumbing command called &lt;code&gt;hash-object&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://git-scm.com/docs/git-hash-object"&gt;hash-object&lt;/a&gt; will take something and compute its object ID. For example we can compute the object ID of the string 'Hello World'.&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Hello World"&lt;/span&gt; | git hash-object &lt;span class="nt"&gt;--stdin&lt;/span&gt;
557db03de997c86a4a028e1ebd3a1ceb225be238
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You can try this on your machine and you should see the exact same output as above. &lt;/p&gt;

&lt;p&gt;When we ask git to track a file this is exactly what happens in order to compute an ID to store the information against. &lt;/p&gt;

&lt;p&gt;We can take this command one step further and ask git to take the string "Hello World" and store it as an object within its object store.&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Hello World"&lt;/span&gt; | git hash-object &lt;span class="nt"&gt;--stdin&lt;/span&gt; &lt;span class="nt"&gt;-w&lt;/span&gt;
557db03de997c86a4a028e1ebd3a1ceb225be238
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now if we look at our .git directory tree again we will see some additional files and directories.&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ tree .git
.git
|___branches
|___config
|___description
|___HEAD
|___hooks
| |___applypatch-msg.sample
| |___commit-msg.sample
| |___post-update.sample
| |___pre-applypatch.sample
| |___pre-commit.sample
| |___pre-push.sample
| |___pre-rebase.sample
| |___prepare-commit-msg.sample
| |___update.sample
|___info
| |___exclude
|___objects
| |___55
| | |___7db03de997c86a4a028e1ebd3a1ceb225be238
| |___info
| |___pack
|___refs
| |___heads
| |___tags
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;We can see that under the &lt;code&gt;objects&lt;/code&gt; directory a new subdirectory has been created: &lt;code&gt;55&lt;/code&gt; with an object of id &lt;code&gt;7db03de997c86a4a028e1ebd3a1ceb225be238&lt;/code&gt; stored within, note that the first two characters of the SHA1 are omitted from the object files name.&lt;/p&gt;

&lt;p&gt;As I said earlier, git stores every object against its computed SHA1, to make the directory structure a little simpler, git takes the first two characters of the SHA1 and uses it as the directory for the object.&lt;/p&gt;

&lt;p&gt;If we recall, our "Hello World" strings computed SHA1 was &lt;code&gt;557db03de997c86a4a028e1ebd3a1ceb225be238&lt;/code&gt; which means the directory named &lt;code&gt;55&lt;/code&gt; should be our string "Hello World". We can verify this using the &lt;code&gt;cat-file&lt;/code&gt; command.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://git-scm.com/docs/git-cat-file"&gt;cat-file&lt;/a&gt; is a git plumming command that can display the content, type and size of objects within gits object store.&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git cat-file 557db03de997c86a4a028e1ebd3a1ceb225be238 -p
Hello World
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;That's git at it's lowest level, you'll almost never use those commands directly in your day to day use of git. &lt;/p&gt;

&lt;h3&gt;
  
  
  Commits
&lt;/h3&gt;

&lt;p&gt;Let's create some files and directories.&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;docs
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;touch &lt;/span&gt;README.md 
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Hello World"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; README.md
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;If we do a &lt;code&gt;git status&lt;/code&gt; now we should see several untracked files.&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;git status
On branch master

Initial commit

Untracked files:
  &lt;span class="o"&gt;(&lt;/span&gt;use &lt;span class="s2"&gt;"git add &amp;lt;file&amp;gt;..."&lt;/span&gt; to include &lt;span class="k"&gt;in &lt;/span&gt;what will be committed&lt;span class="o"&gt;)&lt;/span&gt;

    README.md
    docs/

nothing added to commit but untracked files present &lt;span class="o"&gt;(&lt;/span&gt;use &lt;span class="s2"&gt;"git add"&lt;/span&gt; to track&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Let's fix that by staging and checking in our new files.&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;git add &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s1"&gt;'Add README and Docs'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;If we run a &lt;code&gt;git log&lt;/code&gt; we should see our new commit with a SHA1 to represent it.&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;git log
commit b82828ed05ef076db09118994c7c036708973b40
Author: Jacob Clark &amp;lt;jacob.clark@&amp;gt;
Date:   Sat Mar 19 00:40:04 2016 +0000

    Add README and Docs
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The SHA1 above &lt;code&gt;b82828ed05ef076db09118994c7c036708973b40&lt;/code&gt; is simply a pointer to an object where git stores the information about that commit.&lt;/p&gt;

&lt;p&gt;If we view the contents of the &lt;code&gt;.git&lt;/code&gt; directory now, we should see several extra objects being stored for the files we have just committed. &lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;tree .git
.git
|___branches
|___COMMIT_EDITMSG
|___config
|___description
|___HEAD
|___hooks
| |___applypatch-msg.sample
| |___commit-msg.sample
| |___post-update.sample
| |___pre-applypatch.sample
| |___pre-commit.sample
| |___pre-push.sample
| |___pre-rebase.sample
| |___prepare-commit-msg.sample
| |___update.sample
|___index
|___info
| |___exclude
|___logs
| |___HEAD
| |___refs
| | |___heads
| | | |___master
|___objects
| |___55
| | |___7db03de997c86a4a028e1ebd3a1ceb225be238
| |___66
| | |___801fba9ba0350874eb1f64b87b6cdb609da859
| |___76
| | |___ebb0f0fd6dfc00be4631fd7019d55536f38ea8
| |___b8
| | |___2828ed05ef076db09118994c7c036708973b40
| |___info
| |___pack
|___refs
| |___heads
| | |___master
| |___tags
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;We can see there are now four objects stored. One might think that is a little strange. We already had our "Hello World" object stored to begin with, we know that git stored our commit as an object and we just checked in three new objects (two text files and a directory), so that &lt;em&gt;should&lt;/em&gt; leave us with 5 objects in the store, lets look at why that isn't the case.&lt;/p&gt;

&lt;p&gt;Take a look at our commit object by running &lt;code&gt;git cat-file b82828ed05ef076db09118994c7c036708973b40 -p&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The SHA1 of your commit will be different to mine as a timestamp is used to calculate it, so just substitute the one above for the one in your &lt;code&gt;git log&lt;/code&gt;.&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;git cat-file b82828ed05ef076db09118994c7c036708973b40 &lt;span class="nt"&gt;-p&lt;/span&gt;
tree 66801fba9ba0350874eb1f64b87b6cdb609da859
author Jacob Clark &amp;lt;jacob.clark@&amp;gt; 1458348004 +0000
committer Jacob Clark &amp;lt;jacob.clark@&amp;gt; 1458348004 +0000

Add README and Docs
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;So here we can see git has stored a bunch of information about the commit we just performed, the tree SHA1, the author, committer and the message. &lt;/p&gt;

&lt;p&gt;Lets take a look at the tree object, again your SHA1 will be different.&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;git cat-file 66801fba9ba0350874eb1f64b87b6cdb609da859 &lt;span class="nt"&gt;-p&lt;/span&gt;
100644 blob 557db03de997c86a4a028e1ebd3a1ceb225be238    README.md
040000 tree 76ebb0f0fd6dfc00be4631fd7019d55536f38ea8    docs
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;A tree is like a directory, it holds several objects, in &lt;code&gt;.git&lt;/code&gt; you're either looking at a tree or an object. A directory in your filesystem is a one to one mapping with a tree in git.&lt;/p&gt;

&lt;p&gt;As I said right at the beginning of this article pretty much everything in git is a pointer. Within this commit we can see two pointers, one to an object and one to a tree. We can see both of these pointers corelate to exactly what we checked in earlier - a &lt;code&gt;README.md&lt;/code&gt; file (now an object) and a directory named &lt;code&gt;docs&lt;/code&gt; (now a tree).&lt;/p&gt;

&lt;p&gt;The text inside our &lt;code&gt;README.md&lt;/code&gt; file was simply "Hello World", this object was already stored in gits object store at the time we checked in our &lt;code&gt;README.md&lt;/code&gt; file, and if we look at the SHA1 listed above we can see it is exactly the same as the SHA1 from the "Hello World" string we manually put into gits object store earlier. &lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;git cat-file 557db03de997c86a4a028e1ebd3a1ceb225be238 &lt;span class="nt"&gt;-p&lt;/span&gt;
Hello World
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Git won't track anything it doesn't need too. Git is intelligent in knowing what it has tracked and what it hasn't, the SHA1 of two identical strings will never change. There was no reason for git to create a second object in the store for the exact same string and SHA1 that we checked in earlier. Instead git simply just created a pointer to it from the commit metadata we saw earlier. &lt;/p&gt;

&lt;p&gt;These types of optimisations is what keeps the performance of git high and alleviates unnecessary storage of objects taking up disk space which just are not needed, which is why we only saw 4 new objects and not 5 earlier.&lt;/p&gt;

&lt;h3&gt;
  
  
  Branches
&lt;/h3&gt;

&lt;p&gt;A branch is no different than a commit - it is simply a pointer to a commit within a repository (the HEAD). &lt;/p&gt;

&lt;p&gt;Git stores branch information within plain text files in the &lt;code&gt;.git/refs/heads&lt;/code&gt; directory, git creates a branch by default called &lt;code&gt;master&lt;/code&gt; which is represented by a file called &lt;code&gt;master&lt;/code&gt; within this directory.&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; .git/refs/heads/master
b82828ed05ef076db09118994c7c036708973b40
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This SHA1 is the pointer to the current location of the branch (the HEAD), if we run a &lt;code&gt;git log&lt;/code&gt; we can see that the SHA1 above is exactly the same as the single commit we just created because that is our current location within that branch.&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;git log
commit b82828ed05ef076db09118994c7c036708973b40
Author: Jacob Clark &amp;lt;jacob.clark@g&amp;gt;
Date:   Sat Mar 19 00:40:04 2016 +0000

    Add README and Docs
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;If we create a new branch called &lt;code&gt;hello-moon&lt;/code&gt; git will begin tracking the location of the branch within &lt;code&gt;.git/refs/heads/hello-moon&lt;/code&gt;.&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;git checkout &lt;span class="nt"&gt;-b&lt;/span&gt; hello-moon
Switched to a new branch &lt;span class="s1"&gt;'hello-moon'&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; .git/refs/heads/hello-moon
b82828ed05ef076db09118994c7c036708973b40
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The above SHA1 is still the same as the &lt;code&gt;master&lt;/code&gt; SHA1 because we haven't changed the location of the branch yet.&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;touch &lt;/span&gt;hello-moon.txt
&lt;span class="nv"&gt;$ &lt;/span&gt;git add &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s1"&gt;'Add hello moon'&lt;/span&gt;
&lt;span class="o"&gt;[&lt;/span&gt;hello-moon 683d9df] Add hello moon
 1 file changed, 0 insertions&lt;span class="o"&gt;(&lt;/span&gt;+&lt;span class="o"&gt;)&lt;/span&gt;, 0 deletions&lt;span class="o"&gt;(&lt;/span&gt;-&lt;span class="o"&gt;)&lt;/span&gt;
 create mode 100644 hello-moon.txt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now git has tracked the new commit and the new file we will now have a new location for the branch &lt;code&gt;hello-moon&lt;/code&gt;.&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; .git/refs/heads/hello-moon
683d9df7e5c7247c4606c86e21c84f89e9a575bb
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;We can do a &lt;code&gt;git cat-file&lt;/code&gt; on this SHA1 to see where this branch is now pointing too.&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;git cat-file 683d9df7e5c7247c4606c86e21c84f89e9a575bb &lt;span class="nt"&gt;-p&lt;/span&gt;                                                                                &lt;span class="o"&gt;(&lt;/span&gt;hello-moon&lt;span class="o"&gt;)&lt;/span&gt; 
tree 0a1b6bbf04e5d9448994cae4b5a2cb7eff14302a
parent b82828ed05ef076db09118994c7c036708973b40
author Jacob Clark &amp;lt;jacob.jh.clark@googlemail.com&amp;gt; 1458386031 +0000
committer Jacob Clark &amp;lt;jacob.jh.clark@googlemail.com&amp;gt; 1458386031 +0000

Add hello moon
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;As we expect - it's pointing to our 'Add hello moon' commit with one new addition, this commit has a parent, every commit in Git has a parent (unless it is the first commit on a branch), parents are how git tracks the history of its objects, if we &lt;code&gt;git cat-file&lt;/code&gt; the parent we can see it is the initial commit we made on the master branch.&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;git cat-file b82828ed05ef076db09118994c7c036708973b40 &lt;span class="nt"&gt;-p&lt;/span&gt;                                                                                &lt;span class="o"&gt;(&lt;/span&gt;hello-moon&lt;span class="o"&gt;)&lt;/span&gt; 
tree 66801fba9ba0350874eb1f64b87b6cdb609da859
author Jacob Clark &amp;lt;jacob.jh.clark@googlemail.com&amp;gt; 1458348004 +0000
committer Jacob Clark &amp;lt;jacob.jh.clark@googlemail.com&amp;gt; 1458348004 +0000

Add README and Docs
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;If we decided on this branch we no longer want the 'Add hello moon' commit we could ask git to reset the branch back to a particular commit.&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git reset --hard b82828ed05ef076db09118994c7c036708973b40
HEAD is now at b82828e Add README and Docs
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now if we cat the branch file one last time we will see we are back to where we first started.&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ cat .git/refs/heads/hello-moon                                                                                                          (hello-moon) 
b82828ed05ef076db09118994c7c036708973b40
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;In conclusion a branch is &lt;em&gt;literally&lt;/em&gt; just a file which points to a particular commits SHA1, nothing more.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;There are some topics that I have not covered in this post such as merges, tags, remotes and what HEAD actually is. I'll be covering these concepts and the above in more detail in a future post.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://git-scm.com/documentation"&gt;git documentation&lt;/a&gt; is fantastic and I highly encourage you to read the 'Git Internals - Plumbing and Porcelain' parts.&lt;/p&gt;

&lt;p&gt;Visit my &lt;a href="https://www.jacobclark.xyz"&gt;website&lt;/a&gt;, follow me on &lt;a href="https://twitter.com/imjacobclark"&gt;Twitter&lt;/a&gt; and &lt;a href="https://github.com/imjacobclark"&gt;GitHub&lt;/a&gt; or view my professional background on &lt;a href="https://uk.linkedin.com/in/imjacobclark"&gt;LinkedIn&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Originally posted at &lt;a href="https://blog.jacobclark.xyz/a-quick-look-at-the-git-object-store"&gt;blog.jacobclark.xyz&lt;/a&gt;&lt;/p&gt;


</description>
      <category>git</category>
      <category>versioncontrol</category>
      <category>sourcecontrol</category>
      <category>history</category>
    </item>
    <item>
      <title>Big-O Explained</title>
      <dc:creator>Jacob Clark</dc:creator>
      <pubDate>Wed, 22 Feb 2017 20:34:06 +0000</pubDate>
      <link>https://forem.com/imjacobclark/big-o-explained</link>
      <guid>https://forem.com/imjacobclark/big-o-explained</guid>
      <description>

</description>
      <category>algorithms</category>
      <category>bigo</category>
      <category>notations</category>
      <category>asymptotic</category>
    </item>
  </channel>
</rss>
