{"id":59320,"date":"2018-08-22T11:00:27","date_gmt":"2018-08-22T08:00:27","guid":{"rendered":"http:\/\/examples.javacodegeeks.com\/?p=59320"},"modified":"2019-04-23T14:18:22","modified_gmt":"2019-04-23T11:18:22","slug":"git-handlebars-example","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-handlebars-example\/","title":{"rendered":"Git Handlebars Example"},"content":{"rendered":"<h2>1. Introduction<\/h2>\n<p>In this post, we feature a comprehensive Example on Git Handlebars. <a href=\"https:\/\/git-scm.com\/\">Git<\/a> is a <a href=\"https:\/\/en.wikipedia.org\/wiki\/Free_and_open-source_software\">free and open source (FOSS)<\/a> <a href=\"https:\/\/en.wikipedia.org\/wiki\/Version_control\">version control system<\/a> that was originally created by <a href=\"https:\/\/www.linkedin.com\/in\/linustorvalds\">Linus Torvalds<\/a> to use for developing the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Linux_kernel\">Linux kernel<\/a>. The Linux kernel being a large piece of software &#8212; with developers working on it from all over the world \u2014 had a large and positive impact on the way Git is designed. Unlike older version control systems \u2014 like RCS and SVN \u2014 Git is decentralized. Instead of a single server being the &#8220;master&#8221;, every developer has a full copy of the code repository history locally. As a result, the initial &#8220;cloning&#8221; of the repository is slower, but subsequent (and much more frequent) operations like <code>commit<\/code>-ing and <code>diff<\/code>-ing are much faster and (can be) entirely local (i.e., not requiring a network connection).<\/p>\n<p><a href=\"http:\/\/www.handlebarsjs.com\">Handlebars.js<\/a> is a Javascript library for building simple, clean logic-less templates based on the <a href=\"http:\/\/mustache.github.com\/\">Mustache Templating Language<\/a>. The focus is on keeping the code (logic) and the view separate.\n<\/p>\n<h2>2. Getting a Handle on Things<\/h2>\n<p>Let&#8217;s start by creating a super-simple Handlebars-powered page. We can get started very simply by creating a basic HTML page and including the Handlebars library in the <code>head<\/code> section of the page:<\/p>\n<p><span style=\"text-decoration: underline\"><em>Adding the Handlebars library<\/em><\/span><\/p>\n<pre class=\"brush:html\">&lt;script type=\"text\/javascript\"\n    src=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/handlebars.js\/4.0.11\/handlebars.min.js\"&gt;\n&lt;\/script&gt;\n<\/pre>\n<p>Now in the body of the page we can add the (very basic) Handlebars template, starting with a version of the <em>Hello World!<\/em> example (what else?):<\/p>\n<p><span style=\"text-decoration: underline\"><em>Defining our Handlebars template<\/em><\/span><\/p>\n<pre class=\"brush:html\">    &lt;script id=\"hello-world-template\" type=\"text\/x-handlebars-template\"&gt;\n      &lt;p&gt;Hello {{adj}} world!&lt;\/p&gt;\n    &lt;\/script&gt;\n<\/pre>\n<p>As you may have already noticed, a lot of the text inside the <code>script<\/code> tag is plain HTML. It&#8217;s the <code>{{adj}}<\/code> part that is interesting: it&#8217;s where the Handlebars magic happens. It is what is called an <strong>expression<\/strong>: Handlebars will replace that expression with its value when it is run.<\/p>\n<p>It is important to note two things here:<\/p>\n<ol>\n<li>The template must be placed within <code>script<\/code> tags, otherwise the <a href=\"https:\/\/html.spec.whatwg.org\/multipage\/parsing.html#unexpected-markup-in-tables\">browser might modify it<\/a>.<\/li>\n<li>The <code>type<\/code> of the <code>script<\/code> tag must be <code>text\/x-handlebars-template<\/code> so that the browser doesn&#8217;t try to parse the template as Javascript (which it isn&#8217;t).<\/li>\n<\/ol>\n<p>Having created the template, we now need to:<\/p>\n<ol>\n<li><strong>Compile<\/strong> the template.<\/li>\n<li>Create a <strong>context<\/strong> to use for the evaluation.<\/li>\n<li>Evaluate the template given its context and then insert the output into the HTML page.<\/li>\n<\/ol>\n<p>Here is the listing of the complete page:<\/p>\n<p><span style=\"text-decoration: underline\"><em>index.html<\/em><\/span><\/p>\n<pre class=\"brush:html; wrap-lines:false\">&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Getting Started with Handlebars&lt;\/title&gt;\n    &lt;script type=\"text\/javascript\" src=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/handlebars.js\/4.0.11\/handlebars.min.js\"&gt;&lt;\/script&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    \n    &lt;script id=\"hello-world-template\" type=\"text\/x-handlebars-template\"&gt;\n      &lt;p&gt;Hello {{adj}} world!&lt;\/p&gt;\n    &lt;\/script&gt;\n    \n    &lt;div id=\"content\"&gt;&lt;\/div&gt;\n\n    &lt;script type=\"text\/javascript\"&gt;\n      var source = document.getElementById(\"hello-world-template\").innerHTML;\n      var template = Handlebars.compile(source);\n      var context = {adj: \"awesome\"};\n      document.getElementById(\"content\").innerHTML = template(context);\n    &lt;\/script&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;\n<\/pre>\n<p>Let&#8217;s look at the code in lines 15-18:<\/p>\n<ul>\n<li><strong>Line 15:<\/strong> read the contents of the template<\/li>\n<li><strong>Line 16:<\/strong> compile the template<\/li>\n<li><strong>Line 17:<\/strong> define our context<\/li>\n<li><strong>Line 18:<\/strong> execute the template with the context to get the compiled HTML &amp; insert it into the page<\/li>\n<\/ul>\n<p>If you load this page in your browser you will see the message <em>Hello awesome world!<\/em> You have now successfully created your first Handlebars template. Congratulations!<\/p>\n<h2>3. Did You Git it?<\/h2>\n<p>Now that we have created something worthwhile, why not put it under version control (we&#8217;re going to want to change it, aren&#8217;t we)? To get started, let&#8217;s initialize a Git repository in the directory where you have just created the <em>index.html<\/em> file.<\/p>\n<pre class=\"brush:bash\">$ cd $HOME\/Code\/git-handlebars\n$ git init\nInitialized empty Git repository in $HOME\/Code\/git-handlebars\/.git\/\n<\/pre>\n<p>Having initialized a Git repository, let&#8217;s take a look at what&#8217;s the current status:<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<pre class=\"brush:bash\">$ git status\nOn branch master\n\nNo commits yet\n\nUntracked files:\n  (use \"git add ...\" to include in what will be committed)\n\n        index.html\n\nnothing added to commit but untracked files present (use \"git add\" to track)\n<\/pre>\n<p>What&#8217;s that? Git is telling is that we haven&#8217;t committed anything yet and it is also helpfully giving us the command to do so (<code>git add<\/code>)!! Also, Git has shown us which file(s) is(are) &#8220;untracked&#8221; (not currently under Git&#8217;s version control). Let&#8217;s take are of that:<\/p>\n<pre class=\"brush:bash\">$ git add index.html\n<\/pre>\n<p>Ok, so Git was very quiet this time. Let&#8217;s check on the status again:<\/p>\n<pre class=\"brush:bash\">$ git status\nOn branch master\n\nNo commits yet\n\nChanges to be committed:\n  (use \"git rm --cached &lt;file&gt;...\" to unstage)\n\n        new file:   index.html\n<\/pre>\n<p>We can see that Git now knows that <code>index.html<\/code> is a new file. To have Git start tracking changes to this file, let&#8217;s <code>commit<\/code> it:<\/p>\n<pre class=\"brush:bash\">$ git commit -m \"My first Handlebars template\"\ngit commit -m \"My first Handlebars template\"\n[master (root-commit) f0787dd] My first Handlebars template\n 1 file changed, 21 insertions(+)\n create mode 100755 index.html\n\n$ git status\nOn branch master\nnothing to commit, working tree clean\n<\/pre>\n<p>We have now added our first file to the Git repository and then we ran git status to confirm that we had a &#8220;clean&#8221; <a href=\"https:\/\/www.youtube.com\/watch?v=1GFIZFXGMXY\">working tree<\/a>.<\/p>\n<h2>4. Handle it With Helpers<\/h2>\n<p>In Handlebars you can&#8217;t directly write Javascript inside a template. Does that mean Handlbars is limited to doing just variable substitutions? Not at all! Handlebars lets you use <strong>helpers<\/strong>, Javascript fuctions that you can call from inside your templates that help you create complex and reusable code. Calling a helper is as simple as using its name: <code>{{helpername}}<\/code>. You can also pass in variables by listing them after the helper&#8217;s name: <code>{{helpername arg1 arg2}}<\/code>. Let us update our little experiment with this new-found knowledge. The updated template looks like:<\/p>\n<p><span style=\"text-decoration: underline\"><em>Updated template<\/em><\/span><\/p>\n<pre class=\"brush:html\">&lt;script id=\"hello-world-template\" type=\"text\/x-handlebars-template\"&gt;\n  &lt;h2&gt;Hello {{adj}} world!&lt;\/h2&gt;\n\n  &lt;p&gt;Now let's add some {{bold 'bold text'}} to this page.&lt;\/p&gt;\n&lt;\/script&gt;\n<\/pre>\n<p>We define our helper in a separate code.js file:<\/p>\n<p><span style=\"text-decoration: underline\"><em>code.js<\/em><\/span><\/p>\n<pre class=\"brush:javascript\">Handlebars.registerHelper('bold', function(str) {\n    str = str || '';\n    return '&lt;strong&gt;' + str + '&lt;\/strong&gt;';\n});\n<\/pre>\n<p>Having made our changes, let&#8217;s take a look at what Git has to say:<\/p>\n<pre class=\"brush:javascript\">$ git status\nOn branch master\nChanges not staged for commit:\n  (use \"git add &lt;file&gt;...\" to update what will be committed)\n  (use \"git checkout -- &lt;file&gt;...\" to discard changes in working directory)\n\n        modified:   index.html\n\nUntracked files:\n  (use \"git add &lt;file&gt;...\" to include in what will be committed)\n\n        code.js\n\nno changes added to commit (use \"git add\" and\/or \"git commit -a\")\n<\/pre>\n<p>As expected, Git shows us that we have modified our <code>index.html<\/code> file and added a new <code>code.js<\/code> file. Let&#8217;s take a look at what&#8217;s changed in the <code>index.html<\/code> file:<\/p>\n<pre class=\"brush:bash\">$ git diff index.html\ndiff --git a\/index.html b\/index.html\nindex 8060315..f0b128f 100755\n--- a\/index.html\n+++ b\/index.html\n@@ -2,11 +2,14 @@\n   &lt;head&gt;\n     &lt;title&gt;Getting Started with Handlebars&lt;\/title&gt;\n     &lt;script type=\"text\/javascript\" src=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/handlebars.js\/4.0.11\/handlebars.min.js\"&gt;&lt;\/script&gt;\n+    &lt;script type=\"text\/javascript\" src=\"code.js\"&gt;&lt;\/script&gt;\n   &lt;\/head&gt;\n   &lt;body&gt;\n\n     &lt;script id=\"hello-world-template\" type=\"text\/x-handlebars-template\"&gt;\n-      &lt;p&gt;Hello {{adj}} world!&lt;\/p&gt;\n+      &lt;h2&gt;Hello {{adj}} world!&lt;\/h2&gt;\n+\n+      &lt;p&gt;Now let's add some {{bold 'bold text'}} to this page.&lt;\/p&gt;\n     &lt;\/script&gt;\n\n     &lt;div id=\"content\"&gt;&lt;\/div&gt;\n<\/pre>\n<p>That&#8217;s great! Everything is as expected. Now let&#8217;s <code>commit<\/code> the changes we have just made:<\/p>\n<pre class=\"brush:bash\">$ git add index.html code.js\n\n$ git commit -m \"Adding a helper to our Handlebars code\"\n[master e9dd43a] Adding a helper to our Handlebars code\n 2 files changed, 8 insertions(+), 1 deletion(-)\n create mode 100755 code.js\n\n$ git status\nOn branch master\nnothing to commit, working tree clean\n<\/pre>\n<h2>5. The Great Escape<\/h2>\n<p>Having committed our code, let&#8217;s open it in a browser and take a look at it. This is what it looks like:<\/p>\n<p><figure id=\"attachment_59363\" aria-describedby=\"caption-attachment-59363\" style=\"width: 820px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/08\/JcgGitHandlebars-01-EscapedHtmlCode-wm.png\"><img decoding=\"async\" class=\"wp-image-59363 size-full\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/08\/JcgGitHandlebars-01-EscapedHtmlCode-wm.png\" alt=\"Git Handlebars - angle brackets of HTML have been escaped\" width=\"820\" height=\"300\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/08\/JcgGitHandlebars-01-EscapedHtmlCode-wm.png 820w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/08\/JcgGitHandlebars-01-EscapedHtmlCode-wm-300x110.png 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/08\/JcgGitHandlebars-01-EscapedHtmlCode-wm-768x281.png 768w\" sizes=\"(max-width: 820px) 100vw, 820px\" \/><\/a><figcaption id=\"caption-attachment-59363\" class=\"wp-caption-text\">Oops! The angle brackets of HTML have been escaped!<\/figcaption><\/figure>[ulp id=&#8217;pzgfvmZhgslwSymm&#8217;]<\/p>\n<p>Oh no, Handlebars escaped the angle brackets of our template!<\/p>\n<p>The solution to this particular issue is simple in Handlebars: use <strong>triple curly braces<\/strong> (aka <em>triple-stash<\/em>; <code>{{{...}}}<\/code>) instead of double curly braces to tell Handlebars to <strong>not escape<\/strong> the generated values:<\/p>\n<p><span style=\"text-decoration: underline\"><em>Use triple-stash to avoid HTML escaping<\/em><\/span><\/p>\n<pre class=\"brush:html\">&lt;script id=\"hello-world-template\" type=\"text\/x-handlebars-template\"&gt;\n  &lt;h2&gt;Hello {{adj}} world!&lt;\/h2&gt;\n\n  &lt;p&gt;Now let's add some {{{bold 'bold text'}}} to this page.&lt;\/p&gt;\n&lt;\/script&gt;\n<\/pre>\n<p>Having made the above change, we now have to check it into Git. We can be smart about this and use <code>git amend<\/code> to change the previous commit rather than having to create a new one:<\/p>\n<pre class=\"brush:bash\">$ git commit --amend --no-edit index.html\n\n$ git status\nOn branch master\nnothing to commit, working tree clean\n\n$ git log\ncommit 04e0f19ae6fbdf0113bd8a2aa3ba94d34a3d2d6c (HEAD -&gt; master)\nAuthor: somebody\nDate:   somedate\n\n    Adding a helper to our Handlebars code\n\ncommit ef6c3bc053d2ac5ab3dc244a614255e8ed4246ed\nAuthor: somebody\nDate:   somedate\n\n    My first Handlebars template\n<\/pre>\n<p>Here&#8217;s what we just did:<\/p>\n<ul>\n<li>The <a href=\"https:\/\/git-scm.com\/docs\/git-commit#git-commit---amend\"><code>git commit --amend<\/code><\/a> command amends the previous commit rather than creating a new one. This allows us to correct our mistake quietly and cleanly. NB: running <code>amend<\/code> like this is <span style=\"text-decoration: underline dashed\" title=\"Amended commits are actually entirely new commits and the previous commit will no longer be on your current branch. This has the same consequences as resetting a public snapshot. Avoid amending a commit that other developers have based their work on. This is a confusing situation for developers to be in and it\u2019s complicated to recover from.\">not safe on public commits<\/span> (explanation taken from <a href=\"https:\/\/www.atlassian.com\/git\/tutorials\/rewriting-history\">[1]<\/a>).<\/li>\n<li>The <code>--no-edit<\/code> option tells Git that we don&#8217;t want to edit the comment of the previous Git commit.<\/li>\n<li>We checked the status to ensure we had a clean working directory.<\/li>\n<li>We used <a href=\"https:\/\/git-scm.com\/docs\/git-log\"><code>git log<\/code><\/a> to verify that there are still only 2 commits in the repository&#8217;s history, not the three that would have been present had we not used <code>amend<\/code>.<\/li>\n<\/ul>\n<p>Our page now looks like we actually wanted it to look:<\/p>\n<p><figure id=\"attachment_59362\" aria-describedby=\"caption-attachment-59362\" style=\"width: 820px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/08\/JcgGitHandlebars-02-UnescapedHtmlCode-wm.png\"><img decoding=\"async\" class=\"wp-image-59362 size-full\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/08\/JcgGitHandlebars-02-UnescapedHtmlCode-wm.png\" alt=\"Git Handlebars - output we envisaged in our minds\" width=\"820\" height=\"300\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/08\/JcgGitHandlebars-02-UnescapedHtmlCode-wm.png 820w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/08\/JcgGitHandlebars-02-UnescapedHtmlCode-wm-300x110.png 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/08\/JcgGitHandlebars-02-UnescapedHtmlCode-wm-768x281.png 768w\" sizes=\"(max-width: 820px) 100vw, 820px\" \/><\/a><figcaption id=\"caption-attachment-59362\" class=\"wp-caption-text\">Now we see the output we envisaged in our minds<\/figcaption><\/figure><\/p>\n<h2>6. Express Yourself in Blocks<\/h2>\n<p><strong>Block expressions<\/strong> in Handlebars allow us to specify helpers that invoke our template with a different context than the current one. Block expressions are started with <code>{{#blockHelperName}}<\/code> and end with <code>{{\/blockHelperName}}<\/code>. We start by updating our template to use a helper to generate a list of addresses:<\/p>\n<p><span style=\"text-decoration: underline\"><em>Updated template includes helper to generate list of addresses<\/em><\/span><\/p>\n<pre class=\"brush:html\">&lt;script id=\"hello-world-template\" type=\"text\/x-handlebars-template\"&gt;\n  &lt;h2&gt;Hello {{adj}} world!&lt;\/h2&gt;\n\n  &lt;p&gt;Now let's add some {{{bold 'bold text'}}} to this page.&lt;\/p&gt;\n\n  &lt;p&gt;List of addresses:&lt;\/p&gt;\n  {{#listAddr addrs}}{{addr1}},&lt;br&gt; {{addr2}},&lt;br&gt; {{addr3}}{{\/listAddr}}\n&lt;\/script&gt;\n<\/pre>\n<p>Let&#8217;s add some address information to our context:<\/p>\n<p><span style=\"text-decoration: underline\"><em>Update context to add some addresses<\/em><\/span><\/p>\n<pre class=\"brush:javascript\">      var context = {adj: \"awesome\", addrs : [\n\t{addr1: \"345\", addr2: \"Peach Tree Lane\", addr3: \"Somewhereville\"},\n\t{addr1: \"142\", addr2: \"Orange Street\", addr3: \"Smallville\"},\n\t{addr1: \"249\", addr2: \"Banana Avenue\", addr3: \"Orange County, CA\"}\n      ]};\n<\/pre>\n<p>Then we register our helper function:<\/p>\n<p><span style=\"text-decoration: underline\"><em>Helper to handle block expressions<\/em><\/span><\/p>\n<pre class=\"brush:javascript\">Handlebars.registerHelper('listAddr', function(items, options) {\n    var out = \"&lt;ol&gt;\";\n    for (i = 0; i &lt; items.length; i++) {\n\tout += \"&lt;li&gt;\" + options.fn(items[i]) + \"&lt;\/li&gt;\";\n    }\n    return out + \"&lt;\/ol&gt;\";\n});\n<\/pre>\n<p>The helper receives <code>addrs<\/code> as its first parameter and an options hash as the second parameter. This options hash contains a special property <code>fn<\/code> which can be invoked with a context just like an ordinary Handlebars helper.<\/p>\n<p>Now our page looks like this:<\/p>\n<p><figure id=\"attachment_59361\" aria-describedby=\"caption-attachment-59361\" style=\"width: 820px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/08\/JcgGitHandlebars-03-WithBlockExpression-wm.png\"><img decoding=\"async\" class=\"wp-image-59361 size-full\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/08\/JcgGitHandlebars-03-WithBlockExpression-wm.png\" alt=\"Git Handlebars - Listing addresses using block expressions\" width=\"820\" height=\"400\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/08\/JcgGitHandlebars-03-WithBlockExpression-wm.png 820w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/08\/JcgGitHandlebars-03-WithBlockExpression-wm-300x146.png 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/08\/JcgGitHandlebars-03-WithBlockExpression-wm-768x375.png 768w\" sizes=\"(max-width: 820px) 100vw, 820px\" \/><\/a><figcaption id=\"caption-attachment-59361\" class=\"wp-caption-text\">Listing addresses using block expressions<\/figcaption><\/figure><\/p>\n<p>As before, we want to commit our changes to the Git repository:<\/p>\n<pre class=\"brush:bash\">$ git status\nOn branch master\nChanges not staged for commit:\n  (use \"git add &lt;file&gt;...\" to update what will be committed)\n  (use \"git checkout -- &lt;file&gt;...\" to discard changes in working directory)\n\n        modified:   code.js\n        modified:   index.html\n\nno changes added to commit (use \"git add\" and\/or \"git commit -a\")\n\n$ git add -u\n\n$ git status\nOn branch master\nChanges to be committed:\n  (use \"git reset HEAD &lt;file&gt;...\" to unstage)\n\n        modified:   code.js\n        modified:   index.html\n<\/pre>\n<p>As a convenience, we used <code>git add -u<\/code> to add all (tracked) updated files to the staging area (instead of <code>git commit index.html code.js<\/code>). Once ready in the staging area, we commit our code to the repository.<\/p>\n<h2>7. Parting Thoughts<\/h2>\n<p>We have learnt a lot about the basics of the Handlebars templating system while also learning how to create a repository in Git, how to add files to it, how to commit and diff them. We also learnt how to correct a commit! Of course, there&#8217;s a lot more to learn on both topics, but I hope this gives you a good start on your journey.<\/p>\n<h2>8. Download the Source Code<\/h2>\n<p>We just saw an example of building a template in Handlebars using Git for version control.<\/p>\n<div class=\"download\"><strong>Download<\/strong><br \/>\nYou can download the full source code of this example here: <a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/08\/GitWithHandlebars.zip\"><strong>GitWithHandlebars.zip<\/strong><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>1. Introduction In this post, we feature a comprehensive Example on Git Handlebars. Git is a free and open source (FOSS) version control system that was originally created by Linus Torvalds to use for developing the Linux kernel. The Linux kernel being a large piece of software &#8212; with developers working on it from all &hellip;<\/p>\n","protected":false},"author":167,"featured_media":27377,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1353],"tags":[1203,1729],"class_list":["post-59320","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-git","tag-git","tag-handlebars"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Git Handlebars Example - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Interested to learn more about Git? Then check out our detailed example on Git Handlebars! You can also download our FREE Git Tutorial Minibook!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-handlebars-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Git Handlebars Example - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Interested to learn more about Git? Then check out our detailed example on Git Handlebars! You can also download our FREE Git Tutorial Minibook!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-handlebars-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Examples Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2018-08-22T08:00:27+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-04-23T11:18:22+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/09\/git-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Harshdeep Jawanda\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@hsjawanda\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Harshdeep Jawanda\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"11 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-handlebars-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-handlebars-example\/\"},\"author\":{\"name\":\"Harshdeep Jawanda\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/719cbbebc26b0f3fae478b0d741ca1ba\"},\"headline\":\"Git Handlebars Example\",\"datePublished\":\"2018-08-22T08:00:27+00:00\",\"dateModified\":\"2019-04-23T11:18:22+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-handlebars-example\/\"},\"wordCount\":1326,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-handlebars-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/09\/git-logo.jpg\",\"keywords\":[\"git\",\"Handlebars\"],\"articleSection\":[\"Git\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-handlebars-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-handlebars-example\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-handlebars-example\/\",\"name\":\"Git Handlebars Example - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-handlebars-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-handlebars-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/09\/git-logo.jpg\",\"datePublished\":\"2018-08-22T08:00:27+00:00\",\"dateModified\":\"2019-04-23T11:18:22+00:00\",\"description\":\"Interested to learn more about Git? Then check out our detailed example on Git Handlebars! You can also download our FREE Git Tutorial Minibook!\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-handlebars-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-handlebars-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-handlebars-example\/#primaryimage\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/09\/git-logo.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/09\/git-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-handlebars-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/examples.javacodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Software Development\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/software-development\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Git\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/software-development\/git\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Git Handlebars Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Examples and Code Snippets\",\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/javacodegeeks\",\"https:\/\/x.com\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/719cbbebc26b0f3fae478b0d741ca1ba\",\"name\":\"Harshdeep Jawanda\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/07\/Harshdeep-Jawanda_avatar_1531062985-96x96.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/07\/Harshdeep-Jawanda_avatar_1531062985-96x96.jpg\",\"caption\":\"Harshdeep Jawanda\"},\"description\":\"Armed with a Bachelor of Engineering (Comp. Engg.) degree from University of Pune, India, and a Master of Science (Comp. Sci.) degree from the University of New Mexico, USA, Harshdeep uses his vast experience to develop highly scalable, fault-tolerant distributed systems and come up with innovative solutions to all sorts of problems. As Founder &amp; CTO of Plowns he is using those skills to ensure the all-round growth of children outside the classroom.\",\"sameAs\":[\"https:\/\/x.com\/hsjawanda\"],\"url\":\"https:\/\/examples.javacodegeeks.com\/author\/harshdeep-jawanda\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Git Handlebars Example - Java Code Geeks","description":"Interested to learn more about Git? Then check out our detailed example on Git Handlebars! You can also download our FREE Git Tutorial Minibook!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-handlebars-example\/","og_locale":"en_US","og_type":"article","og_title":"Git Handlebars Example - Java Code Geeks","og_description":"Interested to learn more about Git? Then check out our detailed example on Git Handlebars! You can also download our FREE Git Tutorial Minibook!","og_url":"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-handlebars-example\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2018-08-22T08:00:27+00:00","article_modified_time":"2019-04-23T11:18:22+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/09\/git-logo.jpg","type":"image\/jpeg"}],"author":"Harshdeep Jawanda","twitter_card":"summary_large_image","twitter_creator":"@hsjawanda","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Harshdeep Jawanda","Est. reading time":"11 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-handlebars-example\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-handlebars-example\/"},"author":{"name":"Harshdeep Jawanda","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/719cbbebc26b0f3fae478b0d741ca1ba"},"headline":"Git Handlebars Example","datePublished":"2018-08-22T08:00:27+00:00","dateModified":"2019-04-23T11:18:22+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-handlebars-example\/"},"wordCount":1326,"commentCount":0,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-handlebars-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/09\/git-logo.jpg","keywords":["git","Handlebars"],"articleSection":["Git"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-handlebars-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-handlebars-example\/","url":"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-handlebars-example\/","name":"Git Handlebars Example - Java Code Geeks","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-handlebars-example\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-handlebars-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/09\/git-logo.jpg","datePublished":"2018-08-22T08:00:27+00:00","dateModified":"2019-04-23T11:18:22+00:00","description":"Interested to learn more about Git? Then check out our detailed example on Git Handlebars! You can also download our FREE Git Tutorial Minibook!","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-handlebars-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-handlebars-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-handlebars-example\/#primaryimage","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/09\/git-logo.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/09\/git-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-handlebars-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/examples.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Software Development","item":"https:\/\/examples.javacodegeeks.com\/category\/software-development\/"},{"@type":"ListItem","position":3,"name":"Git","item":"https:\/\/examples.javacodegeeks.com\/category\/software-development\/git\/"},{"@type":"ListItem","position":4,"name":"Git Handlebars Example"}]},{"@type":"WebSite","@id":"https:\/\/examples.javacodegeeks.com\/#website","url":"https:\/\/examples.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Examples and Code Snippets","publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/examples.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/examples.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/719cbbebc26b0f3fae478b0d741ca1ba","name":"Harshdeep Jawanda","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/07\/Harshdeep-Jawanda_avatar_1531062985-96x96.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/07\/Harshdeep-Jawanda_avatar_1531062985-96x96.jpg","caption":"Harshdeep Jawanda"},"description":"Armed with a Bachelor of Engineering (Comp. Engg.) degree from University of Pune, India, and a Master of Science (Comp. Sci.) degree from the University of New Mexico, USA, Harshdeep uses his vast experience to develop highly scalable, fault-tolerant distributed systems and come up with innovative solutions to all sorts of problems. As Founder &amp; CTO of Plowns he is using those skills to ensure the all-round growth of children outside the classroom.","sameAs":["https:\/\/x.com\/hsjawanda"],"url":"https:\/\/examples.javacodegeeks.com\/author\/harshdeep-jawanda\/"}]}},"_links":{"self":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/59320","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/users\/167"}],"replies":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=59320"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/59320\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media\/27377"}],"wp:attachment":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=59320"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=59320"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=59320"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}