<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ Jacob Stopak - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ Jacob Stopak - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Sun, 24 May 2026 22:24:01 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/author/initialcommit/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ Learn Git through Gamification – A Visual Guide to Key Version Control Concepts ]]>
                </title>
                <description>
                    <![CDATA[ Git has many concepts and commands that you’ll need to understand before you feel confident using it. Some of these concepts may sound trivial, especially to someone who has worked with Git before. But like most Git and coding concepts, even the “sim... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/learn-git-through-gamification/</link>
                <guid isPermaLink="false">67c1cfa78df3594301bc3fef</guid>
                
                    <category>
                        <![CDATA[ Git ]]>
                    </category>
                
                    <category>
                        <![CDATA[ GitHub ]]>
                    </category>
                
                    <category>
                        <![CDATA[ gamification  ]]>
                    </category>
                
                    <category>
                        <![CDATA[ coding ]]>
                    </category>
                
                    <category>
                        <![CDATA[ learn coding ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Python ]]>
                    </category>
                
                    <category>
                        <![CDATA[ visualization ]]>
                    </category>
                
                    <category>
                        <![CDATA[ version control ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Jacob Stopak ]]>
                </dc:creator>
                <pubDate>Sun, 02 Mar 2025 06:00:00 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1740686401633/ffd9ac3c-668a-47bf-b2ba-f7cee14e74a8.webp" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Git has many concepts and commands that you’ll need to understand before you feel confident using it. Some of these concepts may sound trivial, especially to someone who has worked with Git before. But like most Git and coding concepts, even the “simple” ones tend to be abstract.</p>
<p>The three concepts that stand out to me as the most fundamental for being able to effectively work with Git at a basic level are:</p>
<ol>
<li><p>The <strong>working directory</strong></p>
</li>
<li><p>The <strong>staging area</strong></p>
</li>
<li><p>The <strong>commit history</strong></p>
</li>
</ol>
<p>In this article, we’ll take a new approach to representing these three concepts: by <em>visualizing them in an immersive, 3D game world!</em></p>
<p>I’ll provide a tangible, visual representation of these key Git concepts which are almost always described in an abstract and confusing way. I hope that this will make them much more intuitive for you to grasp.</p>
<h2 id="heading-table-of-contents">Table of Contents</h2>
<ol>
<li><p><a class="post-section-overview" href="#heading-visualize-your-working-directory">Visualize your Working Directory</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-demystify-your-staging-area">Demystify your Staging Area</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-literally-walk-through-your-commit-history">Literally Walk through your Commit History</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-summary">Summary</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-try-it-yourself">Try it Yourself</a></p>
</li>
</ol>
<h2 id="heading-visualize-your-working-directory">Visualize your Working Directory</h2>
<p>What does your brain picture when you think of the “working directory”? I assume it’s something like a folder structure starting at the project root, containing the code files and subfolders that make up the project.</p>
<p>While that is a fair description of the working directory, it is a bit hard to imagine and misses the segmentation that Git applies to your project. Although the current state of your entire project, folder structure, and code files do reside in the working directory, Git doesn’t really need to do much about that unless certain <em>changes</em> are detected in those files.</p>
<p>Git detects and reports changes to the working directory with the <a target="_blank" href="https://initialcommit.com/blog/git-status">Git status command</a>, which shows output like this:</p>
<pre><code class="lang-bash">Jack@RAPTOR ~/my-project (main)&gt; git status
On branch main
Your branch is up to date with <span class="hljs-string">'origin/main'</span>.

Changes not staged <span class="hljs-keyword">for</span> commit:
  (use <span class="hljs-string">"git add &lt;file&gt;..."</span> to update what will be committed)
  (use <span class="hljs-string">"git restore &lt;file&gt;..."</span> to discard changes <span class="hljs-keyword">in</span> working directory)
        modified:   main.py
        modified:   settings.py

Untracked files:
  (use <span class="hljs-string">"git add &lt;file&gt;..."</span> to include <span class="hljs-keyword">in</span> what will be committed)
        one.py
        three.py
        two.py

no changes added to commit (use <span class="hljs-string">"git add"</span> and/or <span class="hljs-string">"git commit -a"</span>)
</code></pre>
<p>The two relevant sections here are:</p>
<ol>
<li><p><strong>Changes not staged for commit:</strong> Lists existing files tracked by Git which currently contain code changes. In the example above, we see two “modified files”: <code>main.py</code> and <code>settings.py</code>.</p>
</li>
<li><p><strong>Untracked files:</strong> Lists new files in your project that Git doesn’t know about yet. In the example above, we see three new, untracked files: <code>one.py</code>, <code>two.py</code>, and <code>three.py</code>.</p>
</li>
</ol>
<p>When it comes to understanding Git, thinking of the working directory as the changes Git sees in these two sections – <strong>Untracked files</strong> and <strong>Modified files</strong> – is quite helpful.</p>
<p>But the <code>git status</code> command reports these details in the terminal in a purely text-based way, which doesn’t do newer Git users any favors when it comes to wrapping their heads around Git.</p>
<p>Some Git GUI’s do a better job with this (they do provide a safer point-and-click interface, after all), but in my experience, none of them make things <em>obvious at a glance</em>.</p>
<p>Instead, imagine that as a new Git user, you saw this:</p>
<p><a target="_blank" href="https://devlands.com"><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1740587730262/375bef09-b8b8-43e3-a18c-5b1e589b6097.png" alt="Image captured from Devlands, the gamified Git interface and tutorial, showing the untracked files and modified files sections of the working directory wall" class="image--center mx-auto" width="600" height="400" loading="lazy"></a></p>
<p>A nice big wall with clearly delineated sections for <strong>Untracked files</strong> and <strong>Modified files</strong>. Files corresponding to each section are represented as blocks on the wall within that section, clearly labelled with their filename.</p>
<p>More specifically, the blocks representing files <code>one.py</code>, <code>two.py</code>, and <code>three.py</code> are all sitting neatly in the <strong>Untracked files</strong> section, and the blocks representing the files <code>main.py</code> and <code>settings.py</code> are in the <strong>Modified files</strong> section.</p>
<p>This makes it abundantly clear to even a total novice that Git is interpreting these files differently and categorizing them in a logical way. It takes the abstract Git concept of the “working directory” and transforms it into a form that almost anyone can wrap their heads around at a glance.</p>
<p>But something is missing here. Let’s say you run the command <code>git add one.py</code>. This stages the untracked file <code>one.py</code> to be included in the next commit. What happens to the block labelled <code>one.py</code> on the wall?</p>
<h2 id="heading-demystify-your-staging-area">Demystify your Staging Area</h2>
<p>To answer that, let’s move on to the mysterious <a target="_blank" href="https://initialcommit.com/blog/git-add">Git “staging area”</a>. But first, where exactly IS the staging area?</p>
<p>Well, technically any staged file changes are still just sitting in the working directory, which makes things a bit confusing.</p>
<p>Here is how Git reports this in the terminal:</p>
<pre><code class="lang-bash">Jack@RAPTOR ~/D/git-worlds (main)&gt; git status
On branch main
Your branch is up to date with <span class="hljs-string">'origin/main'</span>.

Changes to be committed:
  (use <span class="hljs-string">"git restore --staged &lt;file&gt;..."</span> to unstage)
        new file:   one.py
</code></pre>
<p>As you can see from Git’s output, it now includes the section <strong>Changes to be committed</strong>, which includes the file <code>one.py</code> that was staged with the <code>git add</code> command.</p>
<p>But this is still a bit unclear. Are the staged file changes in <code>one.py</code> still a part of the working directory? Or does Git store them elsewhere?</p>
<p>Well, the answer is… BOTH:</p>
<p><a target="_blank" href="https://devlands.com"><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1740592262850/dc65c06d-0ec6-4de6-bbe9-53307d523e68.png" alt="Image captured from Devlands, the gamified Git interface and tutorial, adding the staged files section onto the working directory wall" class="image--center mx-auto" width="600" height="400" loading="lazy"></a></p>
<p>Here you can see that we zoomed out a bit from the previous image, to reveal a third section of the wall labeled <strong>Staged files</strong>.</p>
<p>Since we ran the command <code>git add one.py</code>, you can see that the corresponding block representing the <code>one.py</code> file moved from the Untracked files column to the Staged files column.</p>
<p>This conveys quite clearly that a file sitting in the staging area is still a part of the working directory (because it is a part of the overall wall), while also being segmented into its own designated space.</p>
<p>From a technical perspective, Git’s staging area is just a file named <strong>index</strong> which lives in the <code>.git/</code> folder. Git builds up the code changes specified by the <code>git add</code> command in this file, which is used as the source for those changes the next time the <code>git commit</code> command is run.</p>
<p>But from a workflow perspective, representing the staging area as a section on the “working directory wall” as in the image above makes things more intuitive to understand.</p>
<p>Next, let’s explore how we might visualize things once the staged changes are turned into a new Git commit and become a part of the active branch.</p>
<h2 id="heading-literally-walk-through-your-commit-history">Literally Walk through your Commit History</h2>
<p>What does your mind’s eye see when you think of Git’s “commit history”?</p>
<p>Well, the prettiest way Git does it in the terminal is by using the <a target="_blank" href="https://initialcommit.com/blog/git-log">Git log command</a>, such as <code>git log --graph --all</code>, which provides output like:</p>
<pre><code class="lang-bash">* commit 88085cff3e2d7657f26eb6479b308526df7d2bba (HEAD -&gt; dev, origin/dev)
| Author: Jacob Stopak &lt;jacob@initialcommit.io&gt;
| Date:   Tue Apr 23 20:31:24 2024 -0700
|
|     Fix <span class="hljs-built_in">command</span> as title clip, ellipses and arrow length <span class="hljs-keyword">in</span> rebase subcommand
|
|     Signed-off-by: Jacob Stopak &lt;jacob@initialcommit.io&gt;
|
*   commit e264605ea26a808c34d4dc2fbc6dad65a8e28c5f
|\  Merge: cb3fa5f b8c071c
| | Author: Jacob Stopak &lt;jacob@initialcommit.io&gt;
| | Date:   Wed Mar 20 19:51:06 2024 -0700
| |
| |     Merge branch <span class="hljs-string">'main'</span> into dev
| |
* | commit cb3fa5f3bdbdcff3d9a8c844cda99d46bf64e337
| | Author: Jacob Stopak &lt;jacob@initialcommit.io&gt;
| | Date:   Sat Mar 9 22:00:49 2024 -0800
| |
| |     Add --staged flag to git restore subcommand
| |
| |     Signed-off-by: Jacob Stopak &lt;jacob@initialcommit.io&gt;
| |
| * commit b8c071cb9a1653748525aa01c2b6bafe06ed9100
|/  Author: Jacob Stopak &lt;jacob@initialcommit.io&gt;
|   Date:   Wed Mar 20 19:50:53 2024 -0700
|
|       Correct license specified <span class="hljs-keyword">in</span> pyproject.toml from MIT to GNU GPLv2
|
|       Signed-off-by: Jacob Stopak &lt;jacob@initialcommit.io&gt;
|
* commit 32a3a3fca583f6c68225b974716e74b557a1a094
| Author: Jacob Stopak &lt;49353917+initialcommit-io@users.noreply.github.com&gt;
| Date:   Tue Aug 22 11:31:38 2023 -0700
|
|     Update README.md
</code></pre>
<p>Unfortunately, this is not so pretty at all. This long, garbled list of commit IDs, names, dates, and commit messages is definitely not something most folks would consider user-friendly.</p>
<p>The <code>--graph</code> option supplied above does show the commit relationships by drawing little lines connecting each commit in the terminal, but the purely text-based nature of this is just not intuitive to most people at a glance.</p>
<p>Now consider the following gamified representation of Git’s commit history:</p>
<p><a target="_blank" href="https://devlands.com"><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1740594184258/8d5a33c8-ad60-4496-a50d-a27fc6b8e752.png" alt="Image captured from Devlands, the gamified Git interface and tutorial, showing the project's commit history and branches" class="image--center mx-auto" width="600" height="400" loading="lazy"></a></p>
<p>Now we’re talkin’! In this image, each Git commit is represented by a white block with a shortened 6-character commit ID.</p>
<p>Each white commit block points back to its parent commit with an arrow, forming very clear chains of commits that make up Git branches.</p>
<p>You might have noticed that some of the white commit blocks have colored blocks sitting on top of them. The green blocks are <a target="_blank" href="https://initialcommit.com/blog/git-branches">branch names</a>, the yellow blocks are <a target="_blank" href="https://initialcommit.com/blog/git-tag">Git tags</a>, the blue block is <a target="_blank" href="https://initialcommit.com/blog/what-is-git-head">Git’s HEAD pointer</a>, and the red blocks are remote-tracking branches. These are collectively referred to as <a target="_blank" href="https://initialcommit.com/blog/what-is-git-head#git-refs-and-heads">Git refs</a>.</p>
<p>Besides being able to easily distinguish between them, representing ref types as different colored blocks clarifies another often-confusing Git concept. In Git, branches (along with other refs types) are just “pointers” to a specific commit. It is tempting to think of a branch as a series of connected commits that share a history – and conceptually this is correct – but in Git, a branch is really just a glorified label pointing to a specific commit.</p>
<p>In this gamified world, you can <em>literally walk through your commit history</em> to see, interact with, and examine the code changes in any commit.</p>
<h2 id="heading-summary">Summary</h2>
<p>In this article, we explored how Git’s fundamental concepts - the working directory, staging area, and commit history - can be difficult to grasp due to their abstract nature.</p>
<p>To make these concepts more accessible, we introduced a gamified, visual approach that transforms them into something tangible: an immersive game world where files and commits are represented as interactive blocks.</p>
<p>By presenting Git this way, beginner coders, students, and developers of all experience levels can intuitively learn Git concepts and commands, and confidently apply them in professional projects.</p>
<h2 id="heading-try-it-yourself">Try it Yourself</h2>
<p>The images in this post were captured in <a target="_blank" href="https://devlands.com">Devlands</a>, the first and only <em>gamified Git interface and tutorial</em>, which I’m building in Python.</p>
<p>In Devlands, not only can you walk through your codebase… You can also learn Git concepts and commands with a character-guided tutorial, simulate and run Git commands directly in the game, see their results applied in the game world in real time, and use AI to explain code you don’t understand.</p>
<p>If you or someone you know is a visual learner, beginner coder, or newer Git user, <a target="_blank" href="https://devlands.com">consider checking it out!</a></p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Visualize Confusing Git Commands with Git-Sim ]]>
                </title>
                <description>
                    <![CDATA[ Git is an essential tool for developers to learn in order to effectively collaborate on source code. But certain Git concepts and commands are notoriously difficult for devs to learn. Not only that, but Git commands often have nuances that lead to va... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/git-sim/</link>
                <guid isPermaLink="false">66d45f35706b9fb1c166b955</guid>
                
                    <category>
                        <![CDATA[ Git ]]>
                    </category>
                
                    <category>
                        <![CDATA[ version control ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Jacob Stopak ]]>
                </dc:creator>
                <pubDate>Mon, 23 Jan 2023 14:57:06 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2023/01/git-sim-merge_01-05-23_09-44-46-1.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Git is an essential tool for developers to learn in order to effectively collaborate on source code. But certain Git concepts and commands are notoriously difficult for devs to learn.</p>
<p>Not only that, but Git commands often have nuances that lead to varying results on the state of your local repository. In addition, even once you learn a specific Git command, you might not use that command for a significant amount of time before needing it again.</p>
<p>This leads devs to repeatedly search Google or Stackoverflow for specific situational Git commands over and over again, praying that parallel results will occur when executing the command locally.</p>
<p>This commonly occurs with notoriously confusing Git commands such as <code>git reset</code>, <code>git merge</code>, and <code>git rebase</code>.</p>
<p>In this article, we'll provide an overview of these 3 commands using a command-line tool called <a target="_blank" href="https://initialcommit.com/blog/git-sim">Git-Sim to visually simulate Git operations in your local repo</a>. This tool will enable us to easily create handy diagrams and animations illustrating how each Git command will affect the state of your own Git repo.</p>
<h2 id="heading-git-reset-how-to-reset-git-head-while-managing-changes"><code>git reset</code> – How to Reset Git HEAD while Managing Changes</h2>
<p>The <a target="_blank" href="https://initialcommit.com/blog/git-reset">git reset command</a> is one that I constantly find myself Googling before I need to use it.</p>
<p>This is partly because there are several commands that you can use to <a target="_blank" href="https://initialcommit.com/blog/undoing-changes-in-git">undo changes in Git</a>, and I want to make sure I'm choosing the right one.</p>
<p>Also, any command that could accidentally lead to "losing work", like <code>git reset --hard</code> is worth taking a few seconds beforehand to make sure you're confident in what you're about to do.</p>
<h3 id="heading-what-does-git-reset-do">What does <code>git reset</code> do?</h3>
<p>In a nutshell, git reset simply moves the tip of the current branch back to a previous commit. In that sense it can be used to "undo" the changes applied by commits between the current commit and the commit you want to reset back to.</p>
<p>Technically speaking, a Git branch is just a name (or label) that points to the newest commit in a chain of commits. This gets moved forward each time you make a new commit on a branch, and therefore always identifies what is known as the <strong>branch head</strong> commit.</p>
<p>The <code>git reset</code> command moves this branch label back to a previous commit, which becomes the new branch head – effectively undoing all the changes in between.</p>
<p>Let's consider a simple example. Assume we have a repository which only tracks 1 file called <code>cheese.txt</code>. The repo has 5 commits, each changing the text content within the file to a different cheese name.</p>
<p>We can illustrate this visually using Git-Sim by running the <code>$ git-sim log</code> command to visually simulate the output of the <code>$ git log</code> command:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/git-sim-log_01-05-23_09-33-17.jpg" alt="Image" width="600" height="400" loading="lazy"></p>
<p><em>Note: we actually simulated this</em> <code>git log</code> output using the git-sim command <code>$ git-sim log</code>, which draws 5 commits in the output image by default.</p>
<p>As you can see, we have a <code>main</code> branch pointing to the commit with ID <code>14c121...</code> with commit message <code>Cheddar</code>.</p>
<p>Now let's say we want to undo the commits changing the content of <code>cheese.txt</code> to "cheddar" and "Swiss". We can do this using the <code>git reset</code> command to reset the <code>main</code> branch back 2 commits, to "Gouda":</p>
<pre><code class="lang-sh">$ git reset HEAD~2
</code></pre>
<p>But if we are ever unsure about the impact this command will have, we can simulate it first using Git-Sim:</p>
<pre><code class="lang-sh">$ git-sim reset HEAD~2
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/git-sim-reset_01-05-23_09-34-16.jpg" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Or if you prefer, the simulation can be rendered as a dynamic video animation using Git-Sim's <code>--animate</code> flag as follows:</p>
<pre><code class="lang-sh">$ git-sim --animate reset HEAD~2
</code></pre>
<div class="embed-wrapper">
        <iframe width="560" height="315" src="https://www.youtube.com/embed/mJHdM6nTjb4" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen="" loading="lazy"></iframe></div>
<p> </p>
<p>As you can see, the Git-Sim simulated output above shows that the <code>main</code> branch and <code>HEAD</code> pointer are reset backward 2 commits to the "Gouda" commit.</p>
<p>In addition, we can see that Git-Sim created a table with 3 columns:</p>
<ul>
<li><p><strong>Changes deleted from</strong></p>
</li>
<li><p><strong>Working directory modifications</strong></p>
</li>
<li><p><strong>Staging area</strong></p>
</li>
</ul>
<p>By default, the <code>git reset</code> command applies the <code>--mixed</code> flag behavior, which moves any changes in reset commits into the working directory.</p>
<p>Git-Sim reflects this in the simulated output above by adding the file <code>cheese.txt</code> into the <strong>Working directory modifications</strong> column.</p>
<p>Now that you've simulated the <code>git reset</code> command using Git-Sim and can clearly see the expected result in the image output above, you can run the actual Git command <code>$ git reset HEAD~2</code> with confidence.</p>
<p>In addition to <code>--mixed</code>, Git-Sim understands <code>--soft</code> and <code>--hard</code> resets. The command <code>$ git-sim reset --soft HEAD~2</code> would keep the undone changes in the <strong>Staging area</strong> column, while the command <code>$ git-sim reset --hard HEAD~2</code> would place the undone changes in the <strong>Changes deleted from</strong> column since a hard reset discards changes to committed files.</p>
<p>Note that <code>git reset</code> doesn't ever delete any commits (even when using the <code>--hard</code> option), which means you don't lose any work at the time of executing it. But keep in mind that commits can become <em>orphaned</em>, meaning that certain commits become unreachable by any branch head. Git will eventually remove these via garbage collection, but they are retrievable for a while if you need them!</p>
<h2 id="heading-git-merge-how-to-merge-changes-from-multiple-branches"><code>git merge</code> – How to Merge Changes from Multiple Branches</h2>
<p>The <a target="_blank" href="https://initialcommit.com/blog/git-merge">git merge command</a> is another tricky one for beginner and intermediate Git users to wrap their heads around. There are several different types of merges that Git performs depending on the circumstances.</p>
<p>To provide a foundation, this sequence of two commands highlights how the merge syntax works:</p>
<pre><code class="lang-sh">$ git checkout &lt;merge-into&gt;
$ git merge &lt;merge-from&gt;
</code></pre>
<p>The first command shows that the <code>&lt;merge-into&gt;</code> branch is the active branch that you currently have checked out in your working directory. Then when you execute the merge, you specify <code>&lt;merge-from&gt;</code> as the branch that you want to merge changes from, into the active branch.</p>
<p>So for example, the following commands would merge changes from the <code>dev</code> branch into <code>main</code>:</p>
<pre><code class="lang-sh">$ git checkout main
$ git merge dev
</code></pre>
<h3 id="heading-git-three-way-merge">Git three-way merge</h3>
<p>The most common merge case occurs when the history of two branches has diverged and the developer wishes to recombine the changes. In this scenario, Git performs something known as a <strong>three-way merge</strong>.</p>
<p>It is called a three-way merge because Git uses three commits to determine how to combine changes in your diverged branches:</p>
<ul>
<li><p>The commit at the tip of branch A</p>
</li>
<li><p>The commit at the tip of branch B</p>
</li>
<li><p>The merge-base of the two branches</p>
</li>
</ul>
<p>We can use Git-Sim to simulate a three-way merge which merges the changes in two new commits on the <code>dev</code> branch into <code>main</code>:</p>
<pre><code class="lang-sh">$ git checkout main
$ git-sim merge dev
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/git-sim-merge_01-05-23_09-44-46.jpg" alt="Image" width="600" height="400" loading="lazy"></p>
<p><em>Three-way merge output in Git-Sim</em></p>
<p>In the example above, the tip of the <code>main</code> branch before the merge is commit <code>14c121</code> ("Cheddar"), and the tip of the <code>dev</code> branch is <code>f42fee</code> ("Asiago"). The third commit used in Git's three-way merge algorithm is commit <code>640bb5</code> which is the <strong>merge base</strong> of the two branches. You can identify this by tracing back both branches until you find the first common ancestor.</p>
<p>Using the content in these 3 commits, Git creates a new <strong>merge commit</strong> (labelled <code>abcdef</code> in the Git-Sim diagram above) which combines the changes from both branches.</p>
<p>Unlike regular commits, a merge commit has two parents instead of one, corresponding to the tips of the two branches that were merged together. These two parent relationships are denoted by the two dotted lines in the image above.</p>
<h3 id="heading-git-fast-forward-merge">Git fast-forward merge</h3>
<p>A <strong>fast-forward merge</strong> in Git occurs when the branch you are merging from is just further along the same line of development as the active branch. Consider the example below:</p>
<pre><code class="lang-sh">$ git-sim <span class="hljs-built_in">log</span>
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/git-sim-log_01-05-23_09-49-08.jpg" alt="Image" width="600" height="400" loading="lazy"></p>
<p>In this case, the <code>dev</code> and <code>main</code> branches have not actually diverged – they both lie along the same line of development. As a result, if you check out the <code>dev</code> branch and try to merge in <code>main</code>, Git doesn't even need to actually need to merge the content from the two branches.</p>
<p>Instead, Git can simply repoint the <code>dev</code> branch ref to the same commit as <code>main</code> points to, which is <code>14c121</code>. (Remember a branch in Git is just a label pointing to a particular commit).</p>
<p>Git-Sim knows how to simulate this type of merge as well:</p>
<pre><code class="lang-sh">$ git checkout dev
$ git-sim merge main
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/git-sim-merge_01-05-23_09-49-49.jpg" alt="Image" width="600" height="400" loading="lazy"></p>
<p><em>Fast-foward merge</em></p>
<p>Note that after checking out the <code>dev</code> branch and merging <code>main</code> into it, the <code>dev</code> branch label was simply <em>fast-forwarded</em> to the same commit as <code>main</code>, and no new merge commit was created.</p>
<p>However, in some cases you may want to <strong>force</strong> Git to create a merge commit even when doing a fast-forward merge.</p>
<p>This might be useful if you want to preserve the history of all merges so that your team knows when a merge was performed. You can do this using the <code>--no-ff</code> flag, which is also supported by Git-Sim:</p>
<pre><code class="lang-sh">$ git checkout dev
$ git-sim merge --no-ff main
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/git-sim-merge_01-05-23_09-50-14.jpg" alt="Image" width="600" height="400" loading="lazy"></p>
<p><em>Forced merge commit</em></p>
<p>In the simulated output image above, Git created a new merge commit <code>abcdef</code> which the <code>dev</code> branch label now points to, even though it was possible to simply fast-forward to the commit pointed to by <code>main</code>.</p>
<p>Keep in mind that even when forcing a merge commit in this way, no divergence of branch history has taken place. Both branches still fall along a single line of development.</p>
<h2 id="heading-git-rebase-how-to-move-the-current-commit-onto-a-new-base-commit"><code>git rebase</code> – How to Move the Current Commit onto a New Base Commit</h2>
<p>Lastly, we'll briefly cover one specific scenario of the standard <a target="_blank" href="https://initialcommit.com/blog/git-rebase">git rebase</a> command. Instead of merging the contents of two branches, <code>git rebase &lt;new-base&gt;</code> reapplies the commits reachable by the current branch onto a new base commit, specified by <code>&lt;new-base&gt;</code>.</p>
<p>By default, <code>git rebase</code> runs in <strong>standard mode</strong>, which is what we'll be discussing here. The <code>-i</code> flag allows rebase to run in <strong>interactive mode</strong>, but that is out of the scope of this article.</p>
<p>Using our previous example repo, let's note the 2 new commits added to the <code>dev</code> branch <code>ead5cc</code> ("Fontina") and <code>f42fee</code> ("Asiago"):</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/git-sim-log_01-05-23_09-53-00.jpg" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Then we want to move these 2 new commits to the tip of the <code>main</code> branch using the <code>git rebase</code> command. This can be simulated using the commands:</p>
<pre><code class="lang-sh">$ git checkout dev
$ git-sim rebase main
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/git-sim-rebase_01-05-23_09-53-34.jpg" alt="Image" width="600" height="400" loading="lazy"></p>
<p>In the simulated output above, the dotted lines show how the 2 new commits on the <code>dev</code> branch are rebased onto the tip of <code>main</code>.</p>
<p>In a standard rebase, Git identifies the number of commits to rebase by walking back from the tip of the active branch until a common ancestor commit is found between the two branches.</p>
<p>Of course, this common ancestor already exists on the destination branch, so the rebase does not need to include it, and can end at that point.</p>
<p>In this case, the two commits on the <code>dev</code> branch that don't yet exist on <code>main</code> are <code>ead5cc</code> ("Fontina") and <code>f42fee</code> ("Asiago"). These get rebased onto <code>main</code> as shown by the dotted lines above. Since commit <code>640bb5</code> ("Gouda") already exists on <code>main</code>, it is not included in the rebase.</p>
<p>Note that rebasing in Git actually rewrites commit history, since each commit ID depends on that commit's content <em>and</em> the history that comes before it.</p>
<p>Even if the content in the two rebased commits in the example above applies cleanly to the <code>main</code> branch, new commit ID's must be calculated since their history now differs from when they were applied to the <code>dev</code> branch.</p>
<p>For this reason, a good rule of thumb is to <strong>only rebase commits locally that haven't yet been pushed to a remote repository</strong>. This will ensure that you and your team maintain a consistent repository state for your project over time.</p>
<h2 id="heading-summary">Summary</h2>
<p>In this article, we use the <a target="_blank" href="https://initialcommit.com/tools/git-sim">Git-Sim tool</a> to provide an overview of 3 notoriously confusing Git commands – <code>git reset</code>, <code>git merge</code>, and <code>git rebase</code>.</p>
<p>We illustrated how to reset Git's HEAD pointer to a previous commit while managing committed files, staged files, and working directory files as desired using the <code>--soft</code>, <code>--mixed</code>, or <code>--hard</code> flags.</p>
<p>Then we outlined the basic merge types in Git, including the 3-way merge and the fast-forward-merge.</p>
<p>Finally, we discussed rebasing branches, which means moving a set of commits onto a new base commit.</p>
<p>For each of these commands, we showed how the Git-Sim command-line tool can be leveraged to create unique, customized simulations of your Git command's effects before running the actual Git command itself.</p>
<h2 id="heading-next-steps">Next Steps</h2>
<p>If you're a visual learner and Git user, I encourage you to try out <a target="_blank" href="https://initialcommit.com/tools/git-sim">Git-Sim</a> to simulate Git commands in your own local repos before running the actual commands.</p>
<p>This will give you the confidence to execute the actual Git commands, and even provide you with visual content to aid in documentation, content-sharing, and teaching others to use Git.</p>
<p>Git-Sim is a free and open-source tool written in Python, so if you're interested in contributing or if you find any bugs, feel free to check out the <a target="_blank" href="https://github.com/initialcommit-com/git-sim">Git-Sim project on GitHub</a> and/or contact me at <a target="_blank" href="mailto:jacob@initialcommit.io">jacob@initialcommit.io</a>!</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Animate Your Git Commit History with git-story ]]>
                </title>
                <description>
                    <![CDATA[ It is often useful for developers to visualize aspects of their code projects. This is especially true for version control systems like Git, where understanding the team's workflow is essential. One way to approach this in Git is to draw a graph like... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/animate-your-git-repo-with-git-story/</link>
                <guid isPermaLink="false">66d45f31052ad259f07e4adc</guid>
                
                    <category>
                        <![CDATA[ Git ]]>
                    </category>
                
                    <category>
                        <![CDATA[ version control ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Jacob Stopak ]]>
                </dc:creator>
                <pubDate>Sun, 17 Jul 2022 17:07:24 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2022/07/git-story-image.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>It is often useful for developers to visualize aspects of their code projects. This is especially true for version control systems like Git, where understanding the team's workflow is essential.</p>
<p>One way to approach this in Git is to draw a graph like the one you see above.</p>
<p>You've probably encountered images like this when <a target="_blank" href="https://initialcommit.com/cluster/git-commands-git-cheat-sheets">learning how to use Git</a>.</p>
<p>This graph depicts a sample commit history in a Git repository.</p>
<p>In Git, commit history is represented as a DAG, or <strong>Directed Acyclic Graph</strong>, which is a type of network graph. Each commit is displayed as a circle and commits are chained together using arrows. Each arrow points from a child commit to its immediate parent.</p>
<p>For the most part, if you want one of these graphs you need to draw it yourself (manually or digitally) – which takes time and effort. Also, these graphs are static and it would be more engaging in certain cases to animate the commit progression in a video format.</p>
<p>For those reasons, I created <a target="_blank" href="https://initialcommit.com/tools/git-story"><strong>Git Story</strong></a>, which lets you easily generate mp4 videos presenting the layout and progression of your Git commit history, all using one single command: <code>git-story</code>.</p>
<h2 id="heading-how-to-visualize-gits-revision-history">How to Visualize Git's Revision History</h2>
<p>In Git, a commit is also known as a revision and represents a set of content changes made at a specific point in time by a specific person.</p>
<p>There are several additional components that help us visually understand our Git history.</p>
<h3 id="heading-commit-properties">Commit Properties</h3>
<p>When committing in Git, human readability is important. Therefore, it's best practice to leave a clear <a target="_blank" href="https://initialcommit.com/blog/git-commit-messages-best-practices">commit message</a> describing your change. This helps other devs viewing the commit history understand the purpose of each revision.</p>
<p>The commit ID is a unique identifier for each commit, generated specifically from the content of each commit. As a Git user, you've probably seen that many Git commands accept a full or partial commit ID as an argument. For that reason, having commit ID's available in Git visualizations can be very useful.</p>
<h3 id="heading-refs-branches-head-and-tags">Refs: Branches, HEAD, and Tags</h3>
<p>When visualizing Git history, it is also useful to know where you are. Git refs (short for references) help you understand how commits are organized in your Git repository.</p>
<p>Refs are labels that Git attaches to specific commits. Branch names, <a target="_blank" href="https://initialcommit.com/blog/what-is-git-head">Git HEAD</a>, and tags are all examples of refs in Git. You can think of a ref as a human-readable name that points to a specific commit.</p>
<h3 id="heading-git-story-video-output">Git Story Video Output</h3>
<p><a target="_blank" href="https://initialcommit.com/tools/git-story"><strong>Git Story</strong></a> parses all of this information for you – commits, relationships, and refs – and animates it as a <code>.mp4</code> video. The best part is that all you need to do is browse to your project in the terminal and run the command <code>git-story</code>.</p>
<p>Below is an example of a video animation generated by Git Story:</p>
<div class="embed-wrapper">
        <iframe width="560" height="315" src="https://www.youtube.com/embed/fI9D-c9wgPs" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen="" loading="lazy"></iframe></div>
<p> </p>
<h2 id="heading-why-i-wrote-git-story-in-python">Why I Wrote Git Story in Python</h2>
<p>I chose to write Git Story in Python since there are two very useful libraries that power this project.</p>
<h3 id="heading-gitpython">GitPython</h3>
<p>The first is called <a target="_blank" href="https://gitpython.readthedocs.io/en/stable/intro.html">GitPython</a>. GitPython is a Python package that provides access to data from Git repositories via a convenient set of methods. This is how Git Story accesses data from the local Git repo in order to animate it:</p>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> git

repo = git.Repo(search_parent_directories=<span class="hljs-literal">True</span>)
</code></pre>
<p>This creates a repository object within the Python program's memory that allows access to the underlying Git objects and their properties. A list of commits can be accessed as follows:</p>
<pre><code class="lang-python">commits = list(repo.iter_commits(REF))

<span class="hljs-comment"># This pulls a list of commits working backwards from REF</span>
<span class="hljs-comment"># REF can be a branch name, tag, HEAD, or commit ID</span>
</code></pre>
<p>Iterating through the list of commits allows access to the properties of each commit, which are used in the next step for generating the animation.</p>
<h3 id="heading-manim">Manim</h3>
<p>The second dependency is called <a target="_blank" href="https://www.manim.community/">Manim</a> which is used to generate animated math videos using a Python API. Manim makes it easy to create Python objects that represent lines, shapes, text, and equations, and place those objects in an animated scene.</p>
<p>Git Story uses Manim to draw the circles, arrows, text, <a target="_blank" href="https://initialcommit.com/blog/git-branches">Git branch</a> names, and refs that represent the portion of your Git history obtained using GitPython.</p>
<p>Here's how the Python code uses Manim to create a red circle for each commit:</p>
<pre><code class="lang-python">circle = Circle(stroke_color=commitFill, fill_color=commitFill, fill_opacity=<span class="hljs-number">0.25</span>)
</code></pre>
<p>And here's how Manim is used to create the arrows between commits:</p>
<pre><code class="lang-python">arrow = Arrow(start=RIGHT, end=LEFT, color=self.fontColor).next_to(circle, LEFT, buff=<span class="hljs-number">0</span>)
</code></pre>
<p>Lastly, here's how these objects are added to an animated scene:</p>
<pre><code class="lang-python">self.play(Create(circle), Create(arrow))
</code></pre>
<h2 id="heading-how-to-install-git-story">How to Install Git Story</h2>
<ol>
<li><p>Install <a target="_blank" href="https://www.manim.community/">manim and manim dependencies for your OS</a></p>
</li>
<li><p>Install GitPython: <code>$ pip3 install gitpython</code></p>
</li>
<li><p>Install git-story: <code>$ pip3 install git-story</code></p>
</li>
</ol>
<h2 id="heading-how-to-use-git-story">How to Use Git Story</h2>
<ol>
<li><p>Open a command-line terminal</p>
</li>
<li><p>Navigate to the root folder of your Git project using <code>cd</code></p>
</li>
<li><p>Execute the command: <code>git-story</code></p>
</li>
</ol>
<p>Running this command will generate an mp4 video animation from the most recent 8 commits in your Git repo. The video file will be placed within the current directory at the path <code>./git-story_media/videos</code>.</p>
<h2 id="heading-how-to-customize-git-storys-output">How to Customize Git Story's Output</h2>
<p>Git Story includes various ways to modify the way your Git repo is represented in the output video. You do this through command-line options and flags.</p>
<p>To specify the number of commits to animate, use the option <code>--commits=X</code>, where <code>X</code> is the number of commits you want to show.</p>
<p>You may want to start animating from a specific commit besides <code>HEAD</code>. You can use the <code>--commit-id=ref</code> option to select the commit to start working backwards from. Instead of <code>ref</code>, you can substitute in a full or partial commit ID, branch name, or <a target="_blank" href="https://initialcommit.com/blog/git-tag">Git tag</a>.</p>
<p>You can use the <code>--reverse</code> flag to animate the commits from newest to oldest, that is reverse-chronological order to more closely match the <a target="_blank" href="https://initialcommit.com/blog/git-log">Git log</a> output.</p>
<p>Try out the <code>--low-quality</code> flag to speed up the animation generation time while testing. Once you're satisfied with the way your animation looks, remove the flag and run the command again to get a final best quality version.</p>
<p>If you prefer a light color scheme instead of the default dark one, you can specify the <code>--light-mode</code> flag.</p>
<p>For presentation purposes, you may want to add an intro title, logo, and outro to your animation. You can do this with the following options:</p>
<pre><code class="lang-sh">$ git-story --show-intro --title <span class="hljs-string">"My Git Repo"</span> --show-outro --outro-top-text <span class="hljs-string">"My Git Repo"</span> --outro-bottom-text <span class="hljs-string">"Thanks for watching!"</span> --logo path/to/logo.png
</code></pre>
<p>Use the <code>--media-dir=path/to/output</code> option to set the output path of the video. This is useful if you don't want extra files to be created within your project.</p>
<p>Finally, you may want to test out the <code>--invert-branches</code> flag if your Git commit history has multiple branches. This flag will flip the order in which branches are parsed, which changes the branch orientation in the output video. Some animations will look better with this flag set and some won't.</p>
<p>Here is a final example showing what the generated video looks like when multiple branches exist in the input commit range:</p>
<div class="embed-wrapper">
        <iframe width="560" height="315" src="https://www.youtube.com/embed/0uj5jRfOaZc" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen="" loading="lazy"></iframe></div>
<p> </p>
<h2 id="heading-summary">Summary</h2>
<p>Git Story is a command-line tool that I wrote in Python to make it easy to create video animations of your Git commit history. Dependencies include Manim and GitPython.</p>
<p>The output video displays the desired set of commits and their relationships, along with branch names, the <code>HEAD</code> commit, and tags.</p>
<p>Git Story has a variety of command-line flags and options that allow you to customize the animation. Run the command <code>git-story -h</code> for the full set of available options.</p>
<p>Feel free to send me an email at <a target="_blank" href="mailto:jacob@initialcommit.io">jacob@initialcommit.io</a> with any comments, questions, or suggestions.</p>
<p>Pull requests are very welcome on the <a target="_blank" href="https://github.com/initialcommit-com/git-story">Git Story GitHub page</a>.</p>
<p>Thanks for reading and happy coding!</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ 7 Questions New Developers Ask When Learning How to Code ]]>
                </title>
                <description>
                    <![CDATA[ If you're relatively new to coding, you surely have some questions – how should you get started, what should you learn first, what does "front-end development" really mean...? In this article, I've shared 7 questions I had when I first started learni... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/questions-new-developers-ask-when-learning-how-to-code/</link>
                <guid isPermaLink="false">66d45f39052ad259f07e4aec</guid>
                
                    <category>
                        <![CDATA[ beginners guide ]]>
                    </category>
                
                    <category>
                        <![CDATA[ learning to code ]]>
                    </category>
                
                    <category>
                        <![CDATA[ programming languages ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Jacob Stopak ]]>
                </dc:creator>
                <pubDate>Mon, 15 Nov 2021 17:14:32 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2021/11/7-questions-new-developers-ask.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>If you're relatively new to coding, you surely have some questions – how should you get started, what should you learn first, what does "front-end development" really mean...?</p>
<p>In this article, I've shared 7 questions I had when I first started learning to code about 20 years ago (man, now I feel old). And I've answered them as thoroughly as possible to help you start your coding journey.</p>
<h2 id="heading-what-programming-language-should-i-learn-first">What programming language should I learn first?</h2>
<p>In my opinion, it doesn't really matter! There are certainly languages that are easier for beginners to pick up, such as Python, Ruby, or JavaScript. But most programming languages have a plethora of things in common, and the core concepts are usually fairly similar.</p>
<p>In most cases, the <em>syntax</em> (the keywords, structure, and semantics) of languages differ much more than the underlying concepts.</p>
<p>Once you know the basics of any programming language, it becomes a lot easier to pick up another one. It is also likely that the language you learn first won't be the central one you end up using at your job or side hustle.</p>
<p>For example, I started with Python back in the day, dabbled with JavaScript and PhP, but now use Java for my job and side hustle.</p>
<p>Of course, you probably don't want to start by learning some obscure and difficult language that isn't commonly used. But you really can't go wrong by starting with a popular modern language like Python, Java, Ruby, or JavaScript.</p>
<p>The most important part isn't what language you learn first, but that you <em>actually start</em> and incrementally improve your skills over time. In a nutshell, <a target="_blank" href="https://initialcommit.com/store/coding-essentials-guidebook-for-developers">focus on mastering essential coding concepts</a> as opposed to the syntax of a specific language.</p>
<h2 id="heading-how-do-we-categorize-programming-languages">How do we categorize programming languages?</h2>
<p>Although most programming languages have a lot in common, there are many ways to organize languages into various categories.</p>
<p>These categories are used to group together languages with a particular feature or trait, although two languages with an overlapping trait might very well differ with respect to others.</p>
<p>Here are 5 of the most useful programming language categories for new devs to know about:</p>
<ul>
<li><p>Compiled programming languages</p>
</li>
<li><p>Interpreted programming languages</p>
</li>
<li><p>Statically-typed programming languages</p>
</li>
<li><p>Dynamically-typed programming languages</p>
</li>
<li><p>Object-oriented programming languages</p>
</li>
</ul>
<p>Below, is a short description of each of these categories, along with a short list of languages in each one.</p>
<h3 id="heading-compiled-programming-languages">Compiled programming languages</h3>
<p>A compiled language is one that uses a <strong>compiler</strong> to convert source code (the code you write yourself) into a form the computer knows how to understand (often called <strong>machine code</strong>).</p>
<p>Usually, the output from the compiler is saved in one or more files called <strong>executables</strong>. Executables can be packaged for sale and distribution in standard formats that make it easy for users to download, install, and run the program.</p>
<p>An important characteristic of the compiling process is that the source code is compiled <em>before</em> the program is executed by the end user. In other words, code compilation typically takes place separately from program execution.</p>
<p>Popular compiled languages:</p>
<ul>
<li><p>C</p>
</li>
<li><p>C++</p>
</li>
<li><p>Java</p>
</li>
<li><p>Rust</p>
</li>
<li><p>Go</p>
</li>
</ul>
<h3 id="heading-interpreted-programming-languages">Interpreted programming languages</h3>
<p>An interpreted language is one that uses an <strong>interpreter</strong> to convert source code (the code you write yourself) into a form the computer knows how to understand.</p>
<p>An interpreter is a program that takes a set of source code written in a specific programming language, converts it into a form the computer can understand, and immediately executes it in real-time.</p>
<p>A primary difference between compiling and interpreting is that the interpreting process has no gap between code conversion and execution – both of these steps happen at program run time or on-the-fly. Whereas with compiling, the code conversion takes place in advance (sometimes far in advance) of program execution.</p>
<p>Popular interpreted languages:</p>
<ul>
<li><p>Python</p>
</li>
<li><p>JavaScript</p>
</li>
<li><p>Ruby</p>
</li>
</ul>
<h3 id="heading-statically-typed-programming-languages">Statically-typed programming languages</h3>
<p>Static-typing means that the data types of the variables in a programming language are known and established at the time the program is compiled. Furthermore, the datatype of a variable is not allowed to change during program compilation or execution.</p>
<p>For example, each time you create a variable in a statically-typed language, you must explicitly specify the datatype of that variable. This datatype could be an integer, string, boolean, and so on. This is called variable <strong>declaration</strong>. Once you declare a variable’s data type, it can only hold that type of data throughout the execution of the program.</p>
<p>Popular statically-typed languages:</p>
<ul>
<li><p>C</p>
</li>
<li><p>C++</p>
</li>
<li><p>Java</p>
</li>
</ul>
<h3 id="heading-dynamically-typed-programming-languages">Dynamically-typed programming languages</h3>
<p>Dynamic-typing means variable data types are established during program execution, also known as <strong>runtime</strong>.</p>
<p>Variable data types are not explicitly stated in the source code and variables can be easily reassigned to store values of any datatype on the fly.</p>
<p>Popular dynamically-typed languages:</p>
<ul>
<li><p>Python</p>
</li>
<li><p>JavaScript</p>
</li>
<li><p>Ruby</p>
</li>
</ul>
<h3 id="heading-object-oriented-programming-languages">Object-oriented programming languages</h3>
<p>Object-oriented programming (OOP) is a coding paradigm that allows programmers to create and work with "objects". An object is a representation or model of something the programmer needs to describe via code.</p>
<p>This probably sounds super vague, because it is. Pretty much anything can be modeled as an "object" in code. Objects often represent real things, such as the products for sale in a store or the customers buying those products.</p>
<p>But objects can also represent digital things such as web forms, and even more abstract stuff like URL endpoints, network sockets, and so on.</p>
<p>Object-oriented programming is usually implemented in a language using <strong>Classes</strong>. You can think of a class as a template (or model) for the type of object that is being created.</p>
<p>A class contains a set of <strong>attributes</strong> (properties or characteristics) that define each object of the class. Classes also contain a set of <strong>methods</strong> (functions) that allow operations to be performed on specific objects of the class.</p>
<p>For example, a "Product" class might have the following attributes:</p>
<ul>
<li><p>Product SKU (unique identifier for each product)</p>
</li>
<li><p>Product name (descriptive name for each product)</p>
</li>
<li><p>Product type</p>
</li>
<li><p>Product price</p>
</li>
<li><p>Product discount</p>
</li>
</ul>
<p>As mentioned, a class is really just a template for <em>creating objects</em>. Creating an object using a class as a template is known as <strong>instantiation</strong>. You can create as many objects as you want from the same class, and each object created is known as an <strong>instance</strong> of that class. The instance is usually stored as a variable in code that you can use as you need it by interacting with its attributes and methods.</p>
<p>Continuing with our example, you can use our "Product" class above to create multiple objects of type "Product". Each product would have its own set of attribute values, such as SKU, name, type, price, and discount.</p>
<p>Representing structured sets of data in this object-oriented fashion can be a very intuitive way for programmers to write and organize their code. This is likely because humans tend to be naturally good at thinking in terms of identifiable entities that exist in the real world.</p>
<h2 id="heading-whats-the-difference-between-front-end-back-end-and-full-stack-development">What's the difference between front-end, back-end, and full-stack development?</h2>
<p>As a newer dev, you've likely browsed job opportunities in tech and noticed frequent mention of the terms "front-end", "back-end" and "full-stack".</p>
<p>These terms generally refer to the part of the application you'll be working on. Moreover, they also imply that you'll be working on a software application, usually a web application or mobile app.</p>
<p>The front end refers to the parts of the application that users (also known as "clients") interact with directly. For a web application, the front end is the collection of webpages (and functionality) that are presented in the user's browser. For a mobile app, the front end is the set of screens that the user interacts with on their mobile device.</p>
<p>Development tasks related to the front end include user experience design, user interface creation, client-side networking, integration and use of client-side libraries, and collecting/validating/submitting user input.</p>
<p>As a front-end dev, you'll implement these tasks primarily using HTML to define the structure of web pages, CSS to add styling, and JavaScript to add interactivity.</p>
<p>The back end refers to the parts of the application that run behind the scenes and aren't presented directly to the user/client.</p>
<p>The back end typically includes a web server which handles HTTP connections received from the front-end client (usually a web browser). The web server handles these connections and directs them to the back-end code which performs the logic necessary to respond to the client. This part of the back end is called <strong>routing</strong> or the <strong>API (application programming interface)</strong>.</p>
<p>The back-end code itself is traditionally a standalone monolith codebase that is deployed as a single unit. But depending on the application's architecture, the back-end code can operate as a set of <strong>serverless</strong> functions running on a cloud service as opposed to a standalone codebase.</p>
<p>The back-end code validates user input, applies business logic, interacts with data storage such as a database, and crafts a response that gets sent back to the front-end client.</p>
<p>Now that we've covered the front end and back end, full-stack development is easy! :) Full stack simply includes both the front end AND back end! The term "full stack" comes from the term "stack" which is a shortened form of "software stack". The software stack is the collection of tools, frameworks, programming languages, and operating systems that are used to support an application.</p>
<h2 id="heading-what-are-some-popular-software-stacks">What are some popular software stacks?</h2>
<p>Now that we know what a software stack is, we'll briefly discuss some popular options for you to choose from.</p>
<h3 id="heading-lamp-stack-linux-apache-mysql-php">LAMP Stack (Linux, Apache, MySQL, PHP)</h3>
<p>The LAMP stack is a time-tested and industry standard back-end stack that uses the Linux operating system as its foundation. On top of that, you use an Apache webserver to handle web requests and direct them to a PHP codebase. Data is stored in a MySQL database, which is a free and open-source (FOSS) relational database platform.</p>
<p>This stack is great for fairly standardized content-serving websites like blogs.</p>
<p>You might notice that I didn't explicitly mention any front-end tools as being a part of this stack – so this means that LAMP is a back-end stack.</p>
<h3 id="heading-mean-stack-mongodb-expressjs-angularjs-nodejs">MEAN Stack (MongoDB, Express.js, Angular.js, Node.js)</h3>
<p>The MEAN stack is a more modern stack that uses the MongoDB unstructured database platform for storing data. You use Express.js as the back-end web framework and Angular.js for the front end. Finally, you use Node.js to run JavaScript on the back end.</p>
<p>A major benefit of the MEAN stack is that all components are designed to natively operate using the JavaScript programming language, via JSON (JavaScript Object Notation).</p>
<p>Note that this stack's components are geared toward both the front end (Angular.js) and back end (MongoDB, Express.js, Node.js), so MEAN can be considered full stack.</p>
<h3 id="heading-mern-stack-mongodb-expressjs-reactjs-nodejs">MERN Stack (MongoDB, Express.js, React.js, Node.js)</h3>
<p>As you can probably see, the MERN stack is very similar to the MEAN stack except it uses React.js library as the front end instead of Angular.js.</p>
<p>This stack is well suited to devs who like React for its flexible and intuitive style of creating user interfaces.</p>
<h3 id="heading-notable-frameworks">Notable frameworks</h3>
<p>I wanted to take a brief moment to point out two other popular backend <em>frameworks</em> (not stacks) that you can incorporate or swap out for specific components of the stacks mentioned above.</p>
<p><strong>Spring Boot</strong> is a Java framework (technically a special case of the broader Spring Framework) that is excellent for developing back-end Java code for web applications and mobile apps. If you are new to Java coding, I highly recommend you check it out.</p>
<p><strong>Django</strong> is a Python framework that is specifically crafted for use with the Python programming language. If you prefer building web apps in Python, it is definitely worth looking into.</p>
<h2 id="heading-how-do-devs-collaborate-on-code-without-being-in-the-same-room">How do devs collaborate on code without being in the same room?</h2>
<p>When I started coding, I opened up a Python text editor on my local machine and created a single file which grew to contain all the code for my project. I quickly found that this became unruly, so I split my code up into several Python <code>.py</code> files (or modules as they are known).</p>
<p>When I coded with a friend, they would usually be sitting there behind me while I typed, or I would be sitting there behind them. If we needed to exchange code snippets or files, we would just send them back and forth via email.</p>
<p>It was years before I learned how devs successfully collaborate while coding, and that it is often done remotely.</p>
<p>The key to successful code collaboration is learning to use a <strong>Version Control System (VCS)</strong>. A VCS is a tool that tracks changes that multiple developers make to code files over time, and enables developers to efficiently work together on the same set files.</p>
<p>Version control systems create a <strong>repository</strong> that stores the data necessary to recreate any version of the code files as they existed at specific points in time. This is called <strong>version control</strong>.</p>
<p>Version control systems are very versatile tools, since they serve multiple useful functions for development teams:</p>
<ul>
<li><p>Tracks changes made to code files</p>
</li>
<li><p>Allows devs to easily share their changes with others and access changes made by others</p>
</li>
<li><p>Offers simple ways for merging code changes made by multiple devs or teams</p>
</li>
<li><p>Provides a full-history backup of a project's code as it evolves over time, and a way to efficiently restore any previous version of the code</p>
</li>
<li><p>Allows developers to easily manage code conflicts made on the same lines of the same files</p>
</li>
<li><p>Provides various other tools to improve team collaboration and efficiency</p>
</li>
</ul>
<p><a target="_blank" href="https://initialcommit.com/blog/Technical-Guide-VCS-Internals">There are many version control systems out there</a>, but you've almost certainly heard of one: GitHub.</p>
<p>Actually, GitHub itself is <em>not</em> a version control system. GitHub is a company that provides online hosting for projects using version control. GitHub gets its name from the specific version control system that it uses: <strong>Git</strong>.</p>
<p><a target="_blank" href="https://initialcommit.com/store/baby-git-guidebook-for-developers">The first version of Git</a> was created in 2005, and it has evolved into by far the most well-known and most popular version control system on the planet. Git is used by the vast majority of development teams today, and it is an <a target="_blank" href="https://initialcommit.com/store/coding-essentials-guidebook-for-developers">essential tool to learn if you plan on coding professionally</a>.</p>
<h2 id="heading-does-it-matter-what-operating-system-i-use">Does it matter what operating system I use?</h2>
<p>When it comes to learning to code for the first time, I would answer this question similarly to the first in this list. I think what matters much more than which operating system you have, is that you get started learning as soon as possible with what you have.</p>
<p>That being said, I feel my answer would be a cop-out if I leave it at that. Let's assume you're trying to make an active decision about what OS to choose for coding work.</p>
<p>Taking into account the fact that there are many subjective reasons people prefer <em>their</em> operating system, in my opinion an operating system that provides access to a quality command-line terminal can be very useful to wrap your head around.</p>
<p>For that reason, my preference is using <a target="_blank" href="https://en.wikipedia.org/wiki/Unix-like">Unix-like</a> operating systems such as a Linux flavor or MacOS if possible for development work. Full disclosure – I develop mostly on MacOS.</p>
<p>My reasoning for this is that learning to work on the command-line (much like learning to use Git) is an <a target="_blank" href="https://www.freecodecamp.org/news/how-to-learn-programming/">essential coding skill to learn</a>. A fully featured and intuitive command line is a core part of software development. In my opinion, Linux and MacOS better incorporate modern command lines than Windows.</p>
<h2 id="heading-what-text-editor-or-ide-should-i-use">What text editor or IDE should I use?</h2>
<p>Text editors and IDE's (Integrated Development Environments) have evolved massively over the years, and developers pick favorites for many reasons.</p>
<p>One reason could be that a particular editor or IDE was created specifically for a particular programming language or framework. Another could be that your company uses a specific editor, so that is the one you learned and stuck with. I found this reason to be especially true in my experience.</p>
<p>If you are primarily working with interpreted, dynamically-typed languages such as Python, JavaScript, Ruby, or PHP, I recommend that you start with a GUI-based editor such as Sublime Text or Visual Studio Code. These are two of the most popular text editors out there and provide a plethora of features and customizations to make your life easier as a developer.</p>
<p>If you work with Java, I recommend either Eclipse or IntelliJ IDEA which offer a multitude of features specifically crafted for working in the Java ecosystem.</p>
<p>Finally, regardless of which editor you choose for your main dev work, I recommend that you learn <a target="_blank" href="https://initialcommit.com/blog/7-versatile-vim-commands">a bit of Vim</a>. Vim is a text editor that is meant to be used directly within your command-line terminal. It definitely takes more time to get used to since you have to learn to use Vim's keyboard commands to interact with your files instead of point-and-click with your mouse.</p>
<p>But in my experience is well worth it. Even if you only learn the basic commands, these will help you immensely if you find yourself browsing through a non-GUI terminal at work, and need to inspect or modify some files.</p>
<p>I highly recommend the built-in Vimtutor program that is downloaded automatically when you install Vim. It walks through the basic directly in your command-line terminal.</p>
<h2 id="heading-summary">Summary</h2>
<p>In this article, I discussed 7 questions commonly asked by new coders. We cast a fairly wide net, covering questions about programmings language selection, software dev stacks, operating systems, and text editors.</p>
<p>If there are any questions you have that I didn't cover, feel free to message me at <a target="_blank" href="mailto:jacob@initialcommit.io">jacob@initialcommit.io</a>.</p>
<h2 id="heading-next-steps">Next steps</h2>
<p>If you got value out of this article, I wrote a book called <a target="_blank" href="https://initialcommit.com/store/coding-essentials-guidebook-for-developers">Coding Essentials Guidebook for Developers</a> which has 14 chapters, each covering a core coding concept, language, or tool.</p>
<p>Topics include computer architecture, the Internet, Command Line, HTML, CSS, JavaScript, Python, Java, SQL, Git, and more.</p>
<p>These topics were meticulously selected to help put together a bigger picture of the development puzzle, instead of focusing on one topic in depth. This might be a good resource for you to check out if you got value out of this article.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Learn Programming – The Guide I Wish I Had When I Started Learning to Code ]]>
                </title>
                <description>
                    <![CDATA[ Just the thought of learning to code can be very intimidating. The word code is mysterious by definition. It implies a technical form of communication that computers, and not humans, are meant to understand. One way many people start learning to code... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-learn-programming/</link>
                <guid isPermaLink="false">66d45f373a8352b6c5a2aa6b</guid>
                
                    <category>
                        <![CDATA[ beginner ]]>
                    </category>
                
                    <category>
                        <![CDATA[ beginners guide ]]>
                    </category>
                
                    <category>
                        <![CDATA[ learn to code ]]>
                    </category>
                
                    <category>
                        <![CDATA[ learning to code ]]>
                    </category>
                
                    <category>
                        <![CDATA[ General Programming ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Jacob Stopak ]]>
                </dc:creator>
                <pubDate>Wed, 06 Oct 2021 15:17:39 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2021/09/The-Programming-Guide-I-Wish-I-Had-When-I-Started-1.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Just the thought of learning to code can be very intimidating. The word <strong>code</strong> is mysterious by definition. It implies a technical form of communication that computers, and not humans, are meant to understand.</p>
<p>One way many people start learning to code is by picking a popular programming language and jumping in head first with no direction. This could take the form of an online coding course, a tutorial project, or a random book purchase on a specific topic.</p>
<p>Rarely do prospective developers start with a roadmap – a bird's eye view of the coding world that outlines a set of relevant programming concepts, languages, and tools that almost 100% of developers use every day.</p>
<p>In this article, I propose one such roadmap. I do this by outlining 14 steps – each one discussing an essential concept, language, or tool – that professional developers use to write code, collaborate, and create professional projects.</p>
<p>I meticulously chose these 14 steps based on my own personal journey learning to code, which spans almost 20 years.</p>
<p>Part of the reason it took me so long to feel comfortable as a developer is that I would learn about specific topics without a broader context of the coding world.</p>
<p>Each of the steps in this article discusses a "coding essential" – something that I believe <strong>is critical to at least know that it exists</strong> at the start of your coding journey.</p>
<p>One final note before listing the steps in the roadmap: of course reading this article will not make you an expert programmer. It isn't meant to. The purpose of this article is to make you aware that each one of these topics exists, and hopefully give you a basic idea of how each one works so you can build on it intelligently going forward.</p>
<h2 id="heading-14-step-roadmap-for-beginner-developers">14 Step Roadmap for Beginner Developers</h2>
<ol>
<li><p><a class="post-section-overview" href="#heading-1-familiarize-yourself-with-computer-architecture-and-data-basics">Familiarize Yourself with Computer Architecture and Data Basics</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-2-learn-how-programming-languages-work">Learn How Programming Languages Work</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-3-understand-how-the-internet-works">Understand How the Internet Works</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-4-practice-some-command-line-basics">Practice Some Command-Line Basics</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-5-build-up-your-text-editor-skills-with-vim">Build Up Your Text Editor Skills with Vim</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-6-take-up-some-html">Take-up Some HTML</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-7-tackle-some-css">Tackle Some CSS</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-8-start-programming-with-javascript">Start Programming with JavaScript</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-9-continue-programming-with-python">Continue Programming with Python</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-10-further-your-knowledge-with-java">Further Your Knowledge with Java</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-11-track-your-code-using-git">Track Your Code using Git</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-12-store-data-using-databases-and-sql">Store Data Using Databases and SQL</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-13-read-about-web-frameworks-and-mvc">Read About Web Frameworks and MVC</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-14-play-with-package-managers">Play with Package Managers</a></p>
</li>
</ol>
<p>Without further ado, let's start at the top!</p>
<h2 id="heading-1-familiarize-yourself-with-computer-architecture-and-data-basics">1) Familiarize Yourself with Computer Architecture and Data Basics</h2>
<p>One of the wonderful things about modern programming languages is that they enable us to create fancy applications without worrying about the nitty-gritty details of the hardware behind the scenes (for the most part).</p>
<p>This is called <strong>abstraction</strong> – the ability to work with higher-level tools (in this case programming languages) that simplify and narrow down the required scope of our understanding and skills.</p>
<p>However, that doesn't mean it's useless to know the basics of the metal that your code is executing on. At the very least, being aware of a few tidbits will help you navigate workplace conversations about high CPU and memory usage.</p>
<p>So, here is a bare minimum of computer architecture basics to get you started:</p>
<p>Your computer's most important parts live on <strong>microchips</strong> (also known as <strong>integrated circuits</strong>).</p>
<p>Microchips rely on an electrical component called a <strong>transistor</strong> to function. Transistors are tiny electrical switches that are either off (0) or on (1) at any given time. A single microchip can contain millions or billions of tiny transistors embedded on it.</p>
<p>Most modern computers have a microchip called the <strong>Central Processing Unit (CPU)</strong>. You can think of it as the computer’s brain. It handles most of the number crunching and logical tasks that the computer performs.</p>
<p>Each CPU has something called an <strong>instruction set</strong>, which is a collection of binary (zeros and ones) commands that the CPU understands. Luckily, we don't really need to worry about these as software devs! That is the power of abstraction.</p>
<p>If the CPU is the logical center of the brain, it is useful to have memory as well to store information temporarily or for the long term.</p>
<p>Computers have <strong>Random Access Memory (RAM)</strong> as "working memory" (or short-term memory) to store information that is actively being used by running programs.</p>
<p>RAM is made up of a collection of <strong>memory addresses</strong>, which can be used to store bits of data. In older languages like C, programmers do have access to working directly with memory addresses using a feature called <strong>pointers</strong>, but this is rare in more modern languages.</p>
<p>Finally, we'll touch on a component you're surely familiar with – the hard drive. In our analogy of the brain, this represents long-term memory. A hard drive is an internal or external device that stores data that should persist even after the computer is turned off.</p>
<p>Before moving on to more details about programming languages, let's spend a second talking about data. But what exactly do we mean by the word <strong>data</strong>?</p>
<p>At a high level, we think of things like text documents, images, videos, emails, files, and folders. These are all high-level data structures that we create and save on our computers every day.</p>
<p>But underneath the hood, a computer chip (like a CPU or RAM chip) has no idea what an "image" or a "video" is.</p>
<p>From a chip’s perspective, all of these structures are stored as long sequences of ones and zeros. These ones and zeros are called <strong>bits</strong>.</p>
<p>Bits are commonly stored in a set of eight at a time, known as a <strong>byte</strong>. A byte is simply a sequence of eight bits, such as <code>00000001</code>, <code>01100110</code>, or <code>00001111</code>. Representing information in this way is called a <strong>binary representation</strong>.</p>
<h2 id="heading-2-learn-how-programming-languages-work">2) Learn How Programming Languages Work</h2>
<p>In the previous section, we mentioned that most computers rely on a CPU, and a CPU can understand a specific set of instructions in the form of ones and zeros.</p>
<p>Therefore, we could theoretically write code that tells the CPU what to do by stringing together long sequences of ones and zeros in a form the CPU understands. Instructions written in binary form like this are called <strong>machine code</strong>.</p>
<p>Sounds horrible to work with, doesn't it? Well it probably is, but I wouldn't know since I mostly use higher-level programming languages like JavaScript, Python, and Java.</p>
<p>A <strong>higher-level programming language</strong> provides a set of human-readable keywords, statements, and syntax rules that are much simpler for people to learn, debug, and work with.</p>
<p>Programming languages provide a means of bridging the gap between the way our human brains understand the world and the way computer brains (CPUs) understand the world.</p>
<p>Ultimately, the code that we write needs to be translated into the binary instructions (machine code) that the CPU understands.</p>
<p>Depending on the language you choose, we say that your code is either <strong>compiled</strong> or <strong>interpreted</strong> into machine code capable of being executed by your CPU. Most programming languages include a program called a <strong>compiler</strong> or an <strong>interpreter</strong> which performs this translation step.</p>
<p>Just to give a few examples – JavaScript and Python are interpreted languages while Java is a compiled language. Whether a language is compiled or interpreted (or some combination of the two) has implications for developer convenience, error handling, performance, and other areas, but we won't get into those details here.</p>
<h2 id="heading-3-understand-how-the-internet-works">3) Understand How the Internet Works</h2>
<p>Whatever type of programming you aspire to do, you'll run into situations where it helps to know how computers interact with each other. This typically occurs over the Internet.</p>
<p>The Internet is nothing more than a global collection of connected computers. In other words, it is a global network. Each computer in the network agrees on a set of rules that enable them to talk to each other. To a computer, "talking" means transferring data.</p>
<p>As we discussed in the previous section, all types of data – web pages, images, videos, emails, and so on – can all be represented as ones and zeros.</p>
<p>Therefore, you can think of the Internet as a very large set of computers that can transfer ones and zeros amongst themselves, in a way that preserves the meaning of that data. The Internet is nothing more than a digital conversation medium.</p>
<p>If the Internet is just a big conversation arena, let’s define the conversation participants.</p>
<p>First, an analogy: most human conversations require at least two participants. In most cases, one person initiates the conversation and the other person responds, assuming they are both present and available.</p>
<p>In Internet speak, the computer initiating the conversation is called the <strong>client</strong>. The computer responding or answering is called the <strong>server</strong>.</p>
<p>For example, let’s say you open a web browser and go to "www.google.com". In this scenario, your web browser is the client. By extension, you can also think of the computer you are working on as the client.</p>
<p>In a more abstract sense, YOU are the client because you are the one initiating the conversation. By typing "www.google.com" into the search bar and clicking , your browser is requesting to start a conversation with one of Google’s computers.</p>
<p>Google’s computer is called the server. It responds by sending the data required to display Google’s web page in your browser. And voilà! Google’s web page appears in front of your eyes. All Internet data transfers utilize this sort of client/server relationship.</p>
<h2 id="heading-4-practice-some-command-line-basics">4) Practice Some Command-Line Basics</h2>
<p>The <strong>Command Line</strong> can be intimidating at first glance. It is often featured in movies as a cryptic black screen with incomprehensible text, numbers, and symbols scrolling by. It is usually associated with an evil hacker or genius techie sidekick.</p>
<p>The truth is that it doesn’t take a genius to use or understand the command line. In fact, it allows us to perform many of the same tasks that we are comfortable doing via a point-and-click mouse.</p>
<p>The main difference is that it primarily accepts input via the keyboard, which can speed up inputs significantly once you get the hang of it.</p>
<p>You can use the Command Line to browse through folders, list a folder’s contents, create new folders, copy and move files, delete files, execute programs, and much more. The window in which you can type commands on the Command Line is called a <strong>terminal</strong>.</p>
<p>Let's walk through a short tutorial of basic navigation commands that will give you a feel for working on the command line.</p>
<p>Once you open your terminal, a typical first question is "<em>Where am I"?</em> We can use the <code>pwd</code> command (which stands for "Print Working Directory") to figure that out. It outputs our current location in the file system which tells us which folder we are currently in.</p>
<p>Try it yourself:</p>
<h3 id="heading-how-to-use-the-command-line">How to Use the Command Line</h3>
<p>If you’re on a Mac, open the Terminal app, which is essentially a Unix Command Line terminal.</p>
<p>If you’re running an operating system without a GUI (Graphical User Interface), like Linux or Unix, you should be at the Command Line by default when you start the computer. If your flavor of Linux or Unix does have a GUI, you’ll need to open the terminal manually.</p>
<p>At the prompt, type <code>pwd</code> and press &lt;ENTER&gt;. The Command Line will print out the path to the folder that you’re currently in.</p>
<p>By default, the active folder when opening the Command Line is the logged-in user’s home directory. This is customizable in case you want the convenience of starting in a different location.</p>
<p>For convenience, the home directory can be referenced using the tilde <code>~</code> character. We will use this in a few examples going forward.</p>
<p>Now that we know what folder we’re in, we can use the <code>ls</code> command to list the contents of the current directory. The <code>ls</code> command stands for "List".</p>
<p>Type <code>ls</code> and press &lt;ENTER&gt;. The contents (files and subfolders) that reside in the current directory are printed to the screen.</p>
<p>Rerun the previous command like this <code>ls -al</code> and press &lt;ENTER&gt;. Now we will get more details about the directory contents, including file sizes, modification dates, and file permissions.</p>
<p>The hyphen in the previous command allows us to set certain flags that modify the behavior of the command. In this case we added the -a flag which will list all directory contents (including hidden files) as well as the -l flag which displays the extra file details.</p>
<p>Next, we can create a new folder using the <code>mkdir</code> command, which stands for "Make Directory". Below we create a new folder called "testdir".</p>
<p>Type <code>mkdir testdir</code> and press &lt;ENTER&gt;. Then type <code>ls</code> and press &lt;ENTER&gt;. You should see your new directory in the list.</p>
<p>To create multiple nested directories at once, use the <code>-p</code> flag to create a whole chain of directories like this: <code>mkdir -p directory1/directory2/directory3</code></p>
<p>The Command Line isn’t that useful if we can only stay in one location, so let’s learn how to browse through different directories in the file system. We can do this via the <code>cd</code> command, which stands for "Change Directory".</p>
<p>First, type <code>cd testdir</code> and press &lt;ENTER&gt;. Then type <code>pwd</code> and press &lt;ENTER&gt;. Note the output now shows that we are inside the "testdir" directory specified in the cd command. We browsed into it!</p>
<p>Type <code>cd ..</code> and press &lt;ENTER&gt;. The <code>..</code> tells the Command Line to browse backwards to the parent directory.</p>
<p>Then type <code>pwd</code> and press &lt;ENTER&gt;. Note the output now shows that you are back in the original directory. We browsed backwards!</p>
<p>Next we’ll learn how to create a new empty file in the current directory.</p>
<p>Type <code>touch newfile1.txt</code> and press &lt;ENTER&gt;. You can use the <code>ls</code> command to see that the new file was created in the current directory.</p>
<p>Now we’ll copy that file from one folder to another using the cp command.</p>
<p>Type <code>cp newfile1.txt testdir</code> and press &lt;ENTER&gt;. Now use the <code>ls</code> and <code>ls testdir</code> commands to see that the new file still exists in the current directory and was copied to the "testdir" directory.</p>
<p>We can also move files instead of copying using the <code>mv</code> command.</p>
<p>Type <code>touch newfile2.txt</code> and press &lt;ENTER&gt; to create a new file. Next, type <code>mv newfile2.txt testdir</code> and press &lt;ENTER&gt; to move the file into the "testdir" folder.</p>
<p>Use the <code>ls</code> and <code>ls testdir</code> commands to confirm that the file has been moved into the "testdir" folder (it should no longer appear in the original location you created it, since it was <em>moved</em> not copied).</p>
<p>The <code>mv</code> command can also be used to rename files.</p>
<p>To do that, type <code>touch newfile3.txt</code> and press &lt;ENTER&gt; to create a new file. Then type <code>mv newfile3.txt cheese.txt</code> and press &lt;ENTER&gt; to update the file’s name. Use <code>ls</code> to confirm that the filed was renamed.</p>
<p>Finally, we can delete files and folders using the <code>rm</code> command.</p>
<p>Type <code>rm cheese.txt</code> and press &lt;ENTER&gt; to remove the file. Use <code>ls</code> to confirm the file was removed.</p>
<p>Type <code>rm -rf testdir</code> and press &lt;ENTER&gt; to remove the "testdir" directory and its contents. Use <code>ls</code> to confirm the directory was removed.</p>
<p>Note that we need to use the <code>-rf</code> flags when removing directories. This forces the removal of the folder and all of its contents.</p>
<h2 id="heading-5-build-up-your-text-editor-skills-with-vim">5) Build Up Your Text Editor Skills with Vim</h2>
<p>At this point, we’ve covered the basics of the Command Line and seen a few examples of how we can work with files without a mouse.</p>
<p>Although we now know how to create, copy, move, rename, and delete files from the Command Line, we haven’t seen how we edit the content of text files in the terminal.</p>
<p>Working with text files in the terminal is important because computer code is nothing more than text saved in an organized set of files.</p>
<p>Sure we could use a fancy text editor like Microsoft Word (or more likely specialized code editors like Sublime or Atom) to write and edit our code, but this is not required. The terminal is often the most convenient place to write and edit code since we usually already have it open to run commands!</p>
<p>There are several excellent text editors created specifically for this purpose, and I recommend <a target="_blank" href="https://www.freecodecamp.org/news/vimrc-configuration-guide-customize-your-vim-editor/">learning the basics of one called Vim</a>.</p>
<p>Vim is one of the oldest text editors around and it is a time-tested gem. Vim stands for "<strong><em>VI</em></strong> i**<em>M</em>**proved" since it is the successor to a tool called <strong><em>Vi</em></strong>.</p>
<p>As mentioned, Vim is a text editor that was built to run directly in the terminal, so we don’t need to open a separate window to work in or use a mouse at all. Vim has a set of commands and modes that allow us to conveniently create and edit text content using only the keyboard.</p>
<p>Vim <a target="_blank" href="https://www.freecodecamp.org/news/how-not-to-be-afraid-of-vim-anymore-ec0b7264b0ae/">does have bit of a learning curve</a>, but with a little bit of practice, the skills you learn will pay dividends throughout your coding career.</p>
<p>Vim is installed by default on many operating systems. To check if it’s installed on your computer, open the Command Line and type <code>vim -v</code>.</p>
<p>If Vim opens in your terminal and shows the version, you’re good to go! If not, you’ll need to install it on your system. (Note that you can quit Vim by typing <code>:q!</code> and pressing ). For more information on installing Vim, see https://www.vim.org.</p>
<p>In my opinion, the quickest and easiest way to learn how to use Vim is to use their built-in tutorial, the <strong>VimTutor</strong>. To run it, ensure that Vim is installed on your system, open the Command Line, type <code>vimtutor</code>, and press .</p>
<p>It is such a good tutorial that there is no reason for me to waste time trying to explain it here. So go do the VimTutor, like now! See you in the next section.</p>
<p>If you still have energy left after you've completed the VimTutor, check out <a target="_blank" href="https://initialcommit.com/blog/7-versatile-vim-commands">these 7 Vim commands that will dramatically improve your productivity</a> as you get started with Vim.</p>
<h2 id="heading-6-take-up-some-html">6) Take-up Some HTML</h2>
<p>You can think of HTML – short for <strong>H</strong>yper<strong>T</strong>ext <strong>M</strong>arkup <strong>L</strong>anguage – as the bones of a web page. It determines the structure of the page by specifying the elements that should be displayed and the order that they should be displayed in.</p>
<p>Every web page that you’ve ever visited in your browser has some HTML associated with it. When you visit a web page, the web server hosting the web page sends over some HTML to your browser. Your browser then reads it and displays it for you.</p>
<p>Most web pages contain a fairly standard set of content, including a title, text content, links to images, navigation links, headers and footers, and more. All of this information is stored as HTML that defines the structure of the page.</p>
<p>One thing to keep in mind is that HTML is not technically a programming language, although it is often referred to as "HTML code".</p>
<p>As we’ll see later, other programming languages enable us to write code that <strong>does stuff</strong>, such as running a set of instructions in sequence. HTML doesn’t <strong>do</strong> anything. We don’t run or execute HTML. HTML just sits there in a file and waits to be sent to a web browser which will display it to the end-user.</p>
<p>In fact, HTML is basically just data. It is data that defines what a web page should look like, nothing more.</p>
<p>So how do you write HTML? HTML uses a standard set of <strong>tags</strong> (basically just labels) to identify the available elements that make up a web page. Each tag is defined using angle brackets.</p>
<p>For example, the <strong>title</strong> tag is defined as <code>&lt;title&gt;My Page Title&lt;/title&gt;</code> and the <strong>paragraph</strong> tag is defined as <code>&lt;p&gt;A bunch of random text content.&lt;/p&gt;</code>.</p>
<p>Each HTML element is made up of a starting tag and an ending tag. The starting tag is just the tag label in between angle brackets, like this:</p>
<p><code>&lt;tagname&gt;</code></p>
<p>This opens the new HTML tag. The ending tag is essentially the same, but it uses a forward slash after the first angle bracket, to mark it as an ending tag:</p>
<p><code>&lt;/tagname&gt;</code></p>
<p>Any text between the two tags is the actual content that the page will display.</p>
<p>Let’s cover a couple of the most common tags in use. The first is the <code>&lt;html&gt;</code> tag. This defines the start of an HTML page. A corresponding <code>&lt;/html&gt;</code> tag (note the forward slash) defines the end of the HTML page. Any content between these tags will be a part of the page.</p>
<p>The second is the <code>&lt;head&gt;</code> tag. This defines additional information that the browser will use to understand the page. Most of the content in this tag is not displayed to the user. A corresponding <code>&lt;/head&gt;</code> tag defines the end of the HEAD section.</p>
<p>Previously, we saw the <code>&lt;title&gt;</code> tag. It defines the title of the web page, which the browser will display in the browser tab. This tag needs to be placed inside the <code>&lt;head&gt;...&lt;/head&gt;</code> section.</p>
<p>Next is the <code>&lt;body&gt;</code> tag. All content inside this tag makes up the main content of the web page. Putting these four tags together looks something like this:</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">html</span>&gt;</span>

    <span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>My Page Title<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span>

    <span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>A bunch of random text content.<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span>

<span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span>
</code></pre>
<p>The simple HTML snippet above represents a simple web page with a title and a single paragraph as body content.</p>
<p>This example brings up a point we didn’t mention in the last section. HTML tags can be nested inside each other. This just means that HTML tags can be placed inside other HTML tags.</p>
<p>HTML provides many other tags to provide a rich set of content to web users. We won't cover them in detail here, but below is a short list for reference:</p>
<ul>
<li><p><code>&lt;p&gt;</code>: A paragraph of text starting on a new line.</p>
</li>
<li><p><code>&lt;h1&gt;</code>: A page heading usually used for page titles.</p>
</li>
<li><p><code>&lt;h2&gt;</code>: A section heading usually used for section titles.</p>
</li>
<li><p><code>&lt;hx&gt;</code>: Where <em>x</em> is a number between 3 and 6, for smaller headings.</p>
</li>
<li><p><code>&lt;img&gt;</code>: An image.</p>
</li>
<li><p><code>&lt;a&gt;</code>: A link.</p>
</li>
<li><p><code>&lt;form&gt;</code>: A form containing fields or inputs for a user to fill out and submit.</p>
</li>
<li><p><code>&lt;input&gt;</code>: An input field for users to enter information, usually within a form.</p>
</li>
<li><p><code>&lt;div&gt;</code>: A content division, used to group together several other elements for spacing purposes.</p>
</li>
<li><p><code>&lt;span&gt;</code>: Another grouping element, but used to wrap text phrases within another element, usually to apply specific formatting to only a specific part of the text content.</p>
</li>
</ul>
<h2 id="heading-7-tackle-some-css">7) Tackle Some CSS</h2>
<p>A web page without CSS – or <strong>C</strong>ascading <strong>S</strong>tyle <strong>S</strong>heets – is like a cake without frosting. A frosting-less cake serves its purpose, but it doesn’t look appetizing!</p>
<p>CSS allows us to associate style properties such as background color, font size, width, height, and more with our HTML elements.</p>
<p>Each style property tells the browser to render the desired effect on the screen. Like HTML, CSS is not technically a programming language. It doesn’t let us perform actions, it simply lets us add styles to bare bones HTML.</p>
<p>Let’s see how to associate CSS styles with our HTML elements. There are three pieces to this puzzle:</p>
<p><strong>The CSS selector:</strong> Used to identify the HTML element or elements we want the style to apply to.</p>
<p><strong>The CSS property name:</strong> The name of the specific style property that we want to add to the matched HTML elements.</p>
<p><strong>The CSS property value:</strong> The value of the style property we want to apply.</p>
<p>Here is an example of how these pieces come together to set the color and font size of a paragraph:</p>
<pre><code class="lang-css"><span class="hljs-selector-tag">p</span> {
  <span class="hljs-attribute">color</span>: red;
  <span class="hljs-attribute">font-size</span>: <span class="hljs-number">12px</span>;
}
</code></pre>
<p>Let’s start at the beginning, before the curly braces. This is where the CSS selector goes. In this case, it is the letter <strong>p</strong> which indicates the <code>&lt;p&gt;</code> (paragraph) HTML tag. This means that the styles inside the curly braces will apply to all <code>&lt;p&gt;</code> tags on the web page.</p>
<p>Let’s move on to what goes inside the curly braces – the styles we want to apply to the targeted elements.</p>
<p>Here we find pairs of CSS properties and values, separated by a colon. The properties (in this case "color" and "font-size") are on the left. The values of these properties (in this case "red" "12px") are on the right. A semicolon ends each property/value pair.</p>
<p>You can probably see how this works. The snippets of CSS code above tell the browser to use red, 12px size letters for all the text placed inside <code>&lt;p&gt;</code> tags.</p>
<p>So how does an HTML page know to include these CSS styles? Enter the <code>&lt;link&gt;</code> HTML tag. Usually, CSS styles are created in separate files (<strong>.css</strong> files) from the HTML. This means we need some way to import them into our HTML files so the browser knows that the styles exist.</p>
<p>The <code>&lt;link&gt;</code> element exists for this purpose. We include <code>&lt;link&gt;</code> elements in the <code>&lt;head&gt;</code> section of HTML files which allow us to specify the external CSS files to import:</p>
<pre><code class="lang-css">&lt;<span class="hljs-selector-tag">head</span>&gt;

    &lt;<span class="hljs-selector-tag">title</span>&gt;<span class="hljs-selector-tag">My</span> <span class="hljs-selector-tag">Page</span> <span class="hljs-selector-tag">Title</span>&lt;/<span class="hljs-selector-tag">title</span>&gt;

    &lt;<span class="hljs-selector-tag">link</span> <span class="hljs-selector-tag">rel</span>="<span class="hljs-selector-tag">stylesheet</span>" <span class="hljs-selector-tag">type</span>="<span class="hljs-selector-tag">text</span>/<span class="hljs-selector-tag">css</span>" <span class="hljs-selector-tag">href</span>="/<span class="hljs-selector-tag">home</span>/<span class="hljs-selector-tag">style</span><span class="hljs-selector-class">.css</span>"&gt;

&lt;/<span class="hljs-selector-tag">head</span>&gt;
</code></pre>
<p>In this example, we are importing the CSS styles specified by the <strong>href</strong> attribute, in this case the file <em>/home/style.css</em>.</p>
<p>In the next 3 sections, we'll (finally) dive into some more technical programming languages!</p>
<p>We'll go over a general overview of JavaScript, Python, and Java, as well as walk through some of the essential coding concepts common to the 3 languages. We will compare and contrast the language features and example code so you can hopefully get a well-rounded understanding of the basics of all three.</p>
<h2 id="heading-8-start-programming-with-javascript">8) Start Programming with JavaScript</h2>
<p>Let’s start by answering the following question: if we can use HTML to build the structure of a web page and CSS to make it look pretty, why do we need JavaScript?</p>
<p>The answer is that we technically don’t. If we are happy with a static site that sits there and looks pretty, we are good to go with just HTML and CSS.</p>
<p>The keyword here is "static". If, however, we want to add dynamic features to our web pages, such as changing content and more complex user interactions, we need to use JavaScript.</p>
<h3 id="heading-what-is-javascript">What is JavaScript?</h3>
<p>So what exactly is JavaScript? JavaScript is a programming language that was created specifically for websites and the Internet. As we mentioned in section 2, most programming languages are either compiled or interpreted, and programs are typically run in a standalone manner.</p>
<p>JavaScript is somewhat unique in this respect in that it was designed to be executed directly inside web browsers. It allows us to write code representing sets of actions that will be executed on our web pages to make our sites much more dynamic.</p>
<p>You can either write JavaScript code in text files named with a <code>.js</code> extension or inside <code>&lt;script&gt;</code> tags directly in the HTML.</p>
<p>For many years, JavaScript code was primarily relegated to running inside web browsers. But the <strong>Node.js</strong> project changed this paradigm by creating a standalone JavaScript environment that could run anywhere.</p>
<p>Instead of being trapped in a browser (that is, client-side), Node.js can be installed locally on any computer to allow the development and execution of JavaScript code. You can also install Node on web servers which allows you to use JavaScript as backend code for applications instead of simply as web browser frontend code.</p>
<p>Now that we've covered some background, let's dive into a few basics of the JavaScript language.</p>
<h3 id="heading-variables-and-assignment-in-javascript">Variables and Assignment in JavaScript</h3>
<p>Variables possibly represent the most fundamental concept in programming. A variable is simply a name or placeholder that is used to reference a particular value.</p>
<p>The word <strong>variable</strong> implies that the stored value can change throughout the execution of the program.</p>
<p>You can use variables to store numbers, strings of text characters, lists, and other data structures that we will talk more about in a minute.</p>
<p>All programming languages use variables, but the syntax varies between different languages.</p>
<p>Variables are useful since we can reference their values throughout our code. This enables us to check their values as needed and perform different actions depending on how the variable’s value changes.</p>
<p>In JavaScript, we declare variables using the <code>let</code> keyword, like this: <code>let x;</code>.</p>
<p>This declares x as a variable that we can use in our code. Note that we added a semicolon at the end of the line. In JavaScript (and many other languages) semicolons are used to specify the end of each code statement.</p>
<p>Now that we have created the variable <em>x</em>, we can assign a value to it using the equals sign, also called the <strong>assignment operator</strong>: <code>x = 10;</code></p>
<p>Here we assigned the number 10 to the variable named <em>x</em>. Now any time we use <em>x</em> in our code, the value 10 will be substituted in.</p>
<p>Both variable declaration and assignment can be done in one line as follows:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> x = <span class="hljs-number">10</span>;
</code></pre>
<h3 id="heading-data-types-in-javascript">Data Types in JavaScript</h3>
<p>In the last section, we stored an integer (whole number) value in the variable named <em>x</em>. You can also store decimal numbers, or <strong>floating-point numbers</strong> as they are known. For example, we could write: <code>let x = 6.6;</code>.</p>
<p>The different types of values we can store in variables are called <strong>data types</strong>. So far we have only seen numeric data types (integers and floating-point numbers), but we are just scratching the surface. We can store text data in variables as well.</p>
<p>In coding terminology, a piece of text is called a <strong>string</strong>. We can store a string value in our variable x by surrounding it in either single or double quotes:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> x = <span class="hljs-string">'Hello there!'</span>;

<span class="hljs-keyword">let</span> y = <span class="hljs-string">"Hey bud!"</span>;
</code></pre>
<p>The next data type we’ll discuss is the <strong>boolean</strong>. A boolean can only hold one of two values, <code>true</code> or <code>false</code> – and they must be all lowercase. In JavaScript, true and false are two keywords used specifically as values for boolean variables:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> x = <span class="hljs-literal">true</span>;

<span class="hljs-keyword">let</span> y = <span class="hljs-literal">false</span>;
</code></pre>
<p>Note that the values <code>true</code> and <code>false</code> don’t appear within quotes the way strings do. If we surround them with quotes, the values would be strings, not booleans.</p>
<p>We often use booleans to control the flow of programs in conditional (if/else) statements which we’ll learn about next.</p>
<h3 id="heading-program-flow-control-statements-in-javascript">Program Flow Control Statements in JavaScript</h3>
<p>Now that we have an understanding of variables and the basic JavaScript data types, let’s take a look at some things we can do with them.</p>
<p>Variables aren't that useful without being able to tell our code to do something with them. We can make our variables do things by using <strong>statements</strong>.</p>
<p>Statements are special keywords that allow us to perform some action in our code, often based on the value of a variable we have defined. Statements let us define the logical flow of our programs, as well as perform many useful actions that will dictate how our programs work.</p>
<h4 id="heading-if-else-statement">If / Else Statement</h4>
<p>The first statement we’ll discuss is the <code>if</code> statement. The <code>if</code> statement allows us to perform some action only when a desired condition is true. Here is how it works:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> x = <span class="hljs-number">10</span>;

<span class="hljs-keyword">if</span> ( x &gt; <span class="hljs-number">5</span> ) {
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">'X is GREATER than 5!'</span>);
} <span class="hljs-keyword">else</span> {
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">'X is NOT GREATER than 5!'</span>);
}
</code></pre>
<p>We defined a variable called <em>x</em> and set its value to 10. Then comes our <code>if</code> statement. After the keyword <code>if</code>, we have a set of parentheses containing the condition to evaluate, in this case, <code>x &gt; 5</code>. We just defined <em>x</em> to equal 10, so we know that this condition is true in this example.</p>
<p>Since the condition in the parentheses is true, the code between the curly braces will be executed, and we will see the string "X is GREATER than 5!" printed to the screen. (We didn't discuss the meaning of <code>console.log()</code>, so for now just know that it prints the value in the parentheses to the screen).</p>
<p>In the same example, we also included an <code>else</code> statement. This allows us to execute specific code in the event that the condition in the condition is <code>false</code>.</p>
<h4 id="heading-while-loops">While Loops</h4>
<p>The next type of statement we’ll discuss is the <strong>while loop</strong>. Loops enable us to repeat a block of code as many times as we desire, without copying and pasting the code over and over again.</p>
<p>For example, let’s assume we need to print a sentence to the screen 5 times. We could do it like this:</p>
<pre><code class="lang-javascript"><span class="hljs-built_in">console</span>.log(<span class="hljs-string">'This is a very important message!'</span>);
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'This is a very important message!'</span>);
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'This is a very important message!'</span>);
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'This is a very important message!'</span>);
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'This is a very important message!'</span>);
</code></pre>
<p>This works fine for only 5 messages, but what about 100, or 1000? We need a better way to repeat pieces of code multiple times, and loops allow us to do this. In coding terminology, repeating a piece of code multiple times is called <strong>iteration.</strong></p>
<p>This following <code>while</code> loop will continue running the block of code inside it as long as the specified condition remains true:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> x = <span class="hljs-number">1</span>;

<span class="hljs-keyword">while</span> ( x &lt;= <span class="hljs-number">100</span> ) {

    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">'This is a very important message!'</span>);

    x = x + <span class="hljs-number">1</span>;

}
</code></pre>
<p>In this example, we initialize <em>x</em> to the value of 1. Then we write a <code>while</code> loop. Similar to the <code>if</code> statement, we add a condition in parentheses. In this case the condition is <code>x &lt;= 100</code>. This condition will be <code>true</code> as long as <em>x</em> is less than or equal to 100.</p>
<p>Next we specify the block of code to execute in the curly braces. First, we print out our message to the console. Then we increment <em>x</em> by 1.</p>
<p>At this point the loop attempts to re-evaluate the condition to see if it’s still <code>true</code>. Variable <em>x</em> now has a value of 2 since it was incremented in the first loop run. The condition is still <code>true</code> since 2 is less than 100.</p>
<p>The code in the loop repeats until <em>x</em> gets incremented to the value of 101. At this point, <em>x</em> is greater than 100 so the condition is now <code>false</code>, and the code in the loop stops executing.</p>
<h3 id="heading-the-html">The HTML</h3>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Boost Your Programming Skills by Reading Git's Code ]]>
                </title>
                <description>
                    <![CDATA[ These days there are plenty of trendy ways to improve your programming skills and knowledge, including: Taking a free or paid online programming course Reading a programming book Picking a personal project and hacking away to learn as you code Fo... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/boost-programming-skills-read-git-code/</link>
                <guid isPermaLink="false">66d45f33f855545810e9345c</guid>
                
                    <category>
                        <![CDATA[ C ]]>
                    </category>
                
                    <category>
                        <![CDATA[ FOSS ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Git ]]>
                    </category>
                
                    <category>
                        <![CDATA[ open source ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Jacob Stopak ]]>
                </dc:creator>
                <pubDate>Wed, 10 Mar 2021 01:40:53 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2021/03/Boost-Your-Programming-Skills-by-Reading-Git-s-Code.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>These days there are plenty of trendy ways to improve your programming skills and knowledge, including:</p>
<ul>
<li><p>Taking a free or paid online programming course</p>
</li>
<li><p>Reading a programming book</p>
</li>
<li><p>Picking a personal project and hacking away to learn as you code</p>
</li>
<li><p>Following along with an online tutorial project</p>
</li>
<li><p>Keeping up to date with relevant programming blogs</p>
</li>
</ul>
<p>Each of these methods will appeal to different people, and each one has elements that will definitely make you a better programmer. If you are an intermediate or advanced coder, it is almost certain that you've tried each of these methods at least once.</p>
<p>However, there is another method that the vast majority of developers overlook, which is a shame in my opinion because it has so much to offer. This method is to <strong>learn by reading, analyzing, and understanding existing, high-quality codebases!</strong></p>
<p>We are lucky to live in a time where good code is often accessible for free via high-quality, free-and-open-source (FOSS) projects. And it takes less than a minute to clone down copies of these codebases to our local machines from sites like GitHub or BitBucket.</p>
<p>Furthermore, modern version control systems like Git allow us to view the code at any point in its development history. Clearly there is a wealth of information right in front of our noses!</p>
<p>In this article, we will discuss the original version of Git's code in order to highlight how reading existing code can help boost your coding skills.</p>
<p>We will cover why it's worth learning about Git's code, how to access Git's code, and review some related C programming concepts.</p>
<p>We will provide an overview of Git's original codebase structure and learn how Git's core functionalities are implemented in code.</p>
<p>Finally, we will recommend some next steps for curious developers to continue learning from Git's code and other projects.</p>
<h2 id="heading-why-learn-about-gits-code">Why Learn About Git's Code?</h2>
<p>Git's codebase is an incredible resource for intermediate developers to further their programming knowledge and skills. Here are 7 reasons why it's worth digging into Git's code:</p>
<ol>
<li><p>Git is probably the most popular software dev tool in use today. In short, if you're a developer, you probably use Git. Learning how Git's code works will give you a deeper understanding of an essential tool you work with every day.</p>
</li>
<li><p>Git is interesting! Git is a versatile tool that solves many interesting problems to allow developers to collaborate on code. As a curious human, I thoroughly enjoyed learning more about it.</p>
</li>
<li><p>Git's code is written in the <strong>C</strong> programming language, which offers a great opportunity for developers to branch out into an important language they may not have used much before.</p>
</li>
<li><p>Git makes use of many important programming concepts, including <em>content-addressable databases, file compression/inflation, hash functions, caching,</em> and a <em>simple</em> <em>data model</em>. Git's code illustrates how these concepts can be implemented in a real project.</p>
</li>
<li><p>Git's code and design are <em>elegant.</em> It is a great example of a functional, minimalist codebase that accomplishes its goal in a clear, effective way.</p>
</li>
<li><p>Git's initial commit is small in size – it is made up of only 10 files, containing less than 1,000 total lines of code. This is very small compared to most other projects and is very manageable to understand in a reasonable amount of time.</p>
</li>
<li><p>The code in Git's initial commit can be compiled and executed successfully. This means you can play with and test the original version of Git's code to see how it works.</p>
</li>
</ol>
<p>Now, let's take a look at how to access the original version of Git's code.</p>
<h2 id="heading-how-to-check-out-gits-initial-commit">How to check out Git's initial commit?</h2>
<p>The official copy of Git's codebase is hosted in <a target="_blank" href="https://github.com/git/git">this public GitHub repository</a>. However, I created a fork of Git's codebase and added extensive inline comments to the source code, to help developers easily read through it line by line.</p>
<p>Since I worked off of the very first commit in Git's history, I named this project <strong>Baby Git</strong>. The Baby Git codebase is located in <a target="_blank" href="https://bitbucket.org/jacobstopak/baby-git">this public BitBucket repository</a>.</p>
<p>I recommend cloning the Baby Git codebase to your local machine by running the following command in your terminal:</p>
<pre><code class="lang-sh">git <span class="hljs-built_in">clone</span> https://bitbucket.org/jacobstopak/baby-git.git
</code></pre>
<p>If you want to stick with Git's original codebase (without the extensive comments I added), use this command instead:</p>
<pre><code class="lang-sh">git <span class="hljs-built_in">clone</span> https://github.com/git/git.git
</code></pre>
<p>Browse into the new <code>git</code> directory by running the command <code>cd git</code>. Feel free to poke around the folders and files in here.</p>
<p>You'll quickly notice that in the current version of Git – the version currently checked out in your working directory – that there are <strong>a lot</strong> of files containing a lot of very long and complicated-looking code.</p>
<p>Clearly this current version of Git is too big for a single developer to realistically get acquainted with in a reasonable amount of time.</p>
<p>Let's simplify things by checking out Git's initial commit, using the command:</p>
<pre><code class="lang-sh">git <span class="hljs-built_in">log</span> --reverse
</code></pre>
<p>This shows a list of Git's commit log in reverse order, starting from Git's initial commit. Note that the first commit ID in the list is <code>e83c5163316f89bfbde7d9ab23ca2e25604af290</code>.</p>
<p>Check out the contents of this commit into the working directory by running the command:</p>
<pre><code class="lang-sh">git checkout e83c5163316f89bfbde7d9ab23ca2e25604af290
</code></pre>
<p>This <a target="_blank" href="https://initialcommit.com/blog/what-is-git-head">puts Git into a <em>detached head state</em></a> and places Git's original code files into the working directory.</p>
<p>Now run the <code>ls</code> command to list these files, and note that there are only 10 that actually contain code! (The 11th is just a README). Understanding the code in these files is totally manageable for an intermediate developer!</p>
<p><strong>Note:</strong> If you're using my Baby Git repository, you'll want to run the command <code>git checkout master</code> to abandon the detached head and move back to the tip of the master branch. This will enable you to see all the inline comments describing how Git's code works line by line!</p>
<h2 id="heading-important-c-concepts-that-will-help-you-understand-gits-code">Important C Concepts that Will Help You Understand Git's Code</h2>
<p>Before diving straight into Git's code, it helps to get a refresher on a few C programming concepts that appear throughout the codebase.</p>
<h3 id="heading-c-header-files">C Header Files</h3>
<p>A C header file is a code file ending in the <code>.h</code> extension. Header files are used to store variables, functions, and other C objects that a developer wants to include in multiple <code>.c</code> source code files using the <code>#include "headerFile.h"</code> directive.</p>
<p>If you're familiar with importing files in Python or Java, this is a comparable procedure.</p>
<h3 id="heading-c-function-prototypes-or-function-signatures">C Function Prototypes (or Function Signatures)</h3>
<p>A function prototype or signature tells the C compiler information about a function definition – the function's name, number of argument, types of arguments, and return type – without providing a function body. They help the C compiler identify function properties in situations where the function body appears after the function is called.</p>
<p>Here is an example of a function prototype:</p>
<pre><code class="lang-c"><span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">multiplyNumbers</span><span class="hljs-params">(<span class="hljs-keyword">int</span> a, <span class="hljs-keyword">int</span> b)</span></span>;
</code></pre>
<h3 id="heading-c-macros">C Macros</h3>
<p>A macro in C is essentially a rudimentary variable that is processed before code compilation in a C program. Macros are created using the <code>#define</code> directive, such as:</p>
<pre><code class="lang-c"><span class="hljs-meta">#<span class="hljs-meta-keyword">define</span> TESTMACRO asdf</span>
</code></pre>
<p>This creates a macro called <code>TESTMACRO</code> with a value of <code>asdf</code>. Wherever the placeholder <code>TESTMACRO</code> is used in the code, it will be replaced by the preprocessor (before code compilation) with the value <code>asdf</code>.</p>
<p>Macros are commonly used in a few ways:</p>
<ul>
<li><p>As a true/false switch by checking whether a macro is defined</p>
</li>
<li><p>To store a simple integer or string value to be replaced in the code in multiple locations</p>
</li>
<li><p>To store a simple (usually one-line) code snippet to be replaced in the code in multiple locations</p>
</li>
</ul>
<p>Macros are convenient tools since they enable developers to update a single line of code which influences the behavior of the code in multiple locations.</p>
<h3 id="heading-c-structs">C Structs</h3>
<p>A struct in C is a grouped set of properties that are related to a single object.</p>
<p>You are probably familiar with Classes in languages such as Java and Python. A struct is a predecessor to a class – it can be thought of as a primitive class with no methods.</p>
<pre><code class="lang-c"><span class="hljs-class"><span class="hljs-keyword">struct</span> <span class="hljs-title">person</span> {</span>

    <span class="hljs-keyword">int</span> person_id;
    <span class="hljs-keyword">char</span> *first_name;
    <span class="hljs-keyword">char</span> *last_name;

};
</code></pre>
<p>This struct represents a person, by grouping together an ID field, along with the person's first and last names. A variable can be instantiated and initialized from this struct as follows:</p>
<pre><code class="lang-c"><span class="hljs-class"><span class="hljs-keyword">struct</span> <span class="hljs-title">person</span> <span class="hljs-title">jacob</span> = {</span> <span class="hljs-number">1</span>, <span class="hljs-string">"Jacob"</span>, <span class="hljs-string">"Stopak"</span> };
</code></pre>
<p>Struct properties can be retrieved using the dot operator:</p>
<pre><code class="lang-c">jacob.person_id
jacob.first_name
jacob.last_name
</code></pre>
<h3 id="heading-c-pointers">C Pointers</h3>
<p>A pointer is a memory address of a variable – it is the memory address at which the value of that variable is stored.</p>
<p>A pointer to an existing variable can be obtained by using the <code>&amp;</code> symbol, and stored in a pointer variable declared with the <code>*</code> symbol:</p>
<pre><code class="lang-c"><span class="hljs-keyword">int</span> age = <span class="hljs-number">21</span>;

<span class="hljs-keyword">int</span>* age_pointer = &amp;age;
</code></pre>
<p>This snippet defines the variable <code>age</code> and assigns it a value of 21. Then it defines a <em>pointer to an integer</em> called <code>age_pointer</code>, and uses the <code>&amp;</code> to obtain the memory address that the value of the age variable is stored at.</p>
<p>Pointers can be <em>dereferenced</em> (i.e. obtain the value stored at the memory address), using the <code>*</code> as well.</p>
<pre><code class="lang-c"><span class="hljs-keyword">int</span> new_age = *age_pointer + <span class="hljs-number">10</span>;
</code></pre>
<p>Continuing from our previous example, we use the <code>*age_pointer</code> syntax to fetch the value stored in the pointer (21), and add 10 to it. So the <code>new_age</code> variable would contain a value of 31.</p>
<p>Now that our short segue into C programming is completed, let's get back to Git's code.</p>
<h2 id="heading-overview-of-gits-codebase-structure">Overview of Git's Codebase Structure</h2>
<p>There are ten relevant code files that make up Git's initial commit. We'll start by briefly discussing these two:</p>
<ul>
<li><p>Makefile</p>
</li>
<li><p>cache.h</p>
</li>
</ul>
<p>We'll discuss <code>Makefile</code> and <code>cache.h</code> first because they are a bit special.</p>
<p><code>Makefile</code> is a build file that contains a set of commands used to build the other source code files into executables.</p>
<p>When you run the command <code>make all</code> from the command line, the Makefile will compile the source code files and spit out the relevant executables for Git's commands. If you're interested, I wrote an <a target="_blank" href="https://initialcommit.com/blog/Learn-Git-Makefile">in-depth guide on Git's makefile</a>.</p>
<p><strong>Note:</strong> If you actually want to compile Git's code locally, which I recommend you do, you'll need to use my Baby Git version of the code mentioned above. The reason is that I made some tweaks to allow Git's original code to compile on modern operating systems.</p>
<p>Next up is the <code>cache.h</code> file, which is Baby Git's only header file. As mentioned above, the header file defines many of the function signatures, structs, macros, and other settings that are used in the <code>.c</code> source code files. If you're curious, I wrote an <a target="_blank" href="https://initialcommit.com/blog/Learn-Git-Header-Files">in-depth guide on Git's header file</a>.</p>
<p>The remaining eight code files are all <code>.c</code> source code files:</p>
<ul>
<li><p><code>init-db.c</code></p>
</li>
<li><p><code>update-cache.c</code></p>
</li>
<li><p><code>read-cache.c</code></p>
</li>
<li><p><code>write-tree.c</code></p>
</li>
<li><p><code>commit-tree.c</code></p>
</li>
<li><p><code>read-tree.c</code></p>
</li>
<li><p><code>cat-file.c</code></p>
</li>
<li><p><code>show-diff.c</code></p>
</li>
</ul>
<p>Each file (except <code>read-cache.c</code>) is named after the Git command that it contains the code for – some probably look familiar to you. For example, the <code>init-db.c</code> file contains the code for the <code>init-db</code> command used to initialize a new Git repository. As you probably guessed, this was the precursor to the <code>git init</code> command.</p>
<p>In fact, each of these <code>.c</code> files (except <code>read-cache.c</code>) contains the code for one of the original eight Git commands. The build process compiles each of these files and creates an executable file (with matching name) for each one. Once these executables are added to the filesystem path, they can be executed similarly to any modern Git command.</p>
<p>So after compiling the code using the <code>make all</code> command, the following executables are produced:</p>
<ul>
<li><p><code>init-db</code>: Initializes a new Git repository. Equivalent to <code>git init</code>.</p>
</li>
<li><p><code>update-cache</code>: Add a file to the staging index. Equivalent to <code>git add</code>.</p>
</li>
<li><p><code>write-tree</code>: Creates a tree object in the Git repository from the current index contents.</p>
</li>
<li><p><code>commit-tree</code>: Creates a new commit object in the Git repository. Equivalent to <code>git commit</code>.</p>
</li>
<li><p><code>read-tree</code>: Print out the contents of a tree from the Git repository.</p>
</li>
<li><p><code>cat-file</code>: Retrieve the the contents of an object from the Git repository, and store it in a temporary file in the current directory. Equivalent to <code>git show</code>.</p>
</li>
<li><p><code>show-diff</code>: Show the differences between files staged in the index and the current versions of those files as they exist in the filesystem. Equivalent to <code>git diff</code>.</p>
</li>
</ul>
<p>These commands are executed individually in sequence, similar to how modern Git commands are executed as a part of standard development workflows.</p>
<p>The one file we haven't discussed yet is <code>read-cache.c</code>. This file contains a set of helper functions that the other <code>.c</code> source code files use to retrieve information from the Git repository.</p>
<p>Now that we've touched on each of the important files in Git's initial commit, let's discuss some of the core programming concepts that allow Git to function.</p>
<h2 id="heading-implementation-of-gits-core-concepts">Implementation of Git's Core Concepts</h2>
<p>In this section, we'll discuss the following programming concepts that Git uses to work its magic, as well as how they were implemented in Git's original code:</p>
<ul>
<li><p>File compression</p>
</li>
<li><p>Hash function</p>
</li>
<li><p>Objects</p>
</li>
<li><p>Current directory cache (staging area)</p>
</li>
<li><p>Content addressable database (object database)</p>
</li>
</ul>
<h3 id="heading-file-compression">File Compression</h3>
<p>File compression, also know as deflation, is used for storage and performance efficiency in Git. This reduces the size of the files that Git stores on disk and increases the speed of data retrieval when Git needs to transfer these files across a network.</p>
<p>This is important since Git's local and network operations need to be as fast as possible. As a part of the data retrieval process, Git decompresses, or inflates, the files to obtain their content.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/03/image-37.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><em>Source: https://initialcommit.com/blog/Learn-Git-Guidebook-For-Developers-Chapter-2</em></p>
<p>File deflation and inflation were implemented in Git's original code using the popular <code>zlib.h</code> C library. This library contains functions, structures, and properties for compressing and decompressing content. Specifically, <code>Zlib</code> defines a <code>z_stream</code> struct that is used to hold the content that is to be deflated or inflated.</p>
<p>The following <code>zlib</code> functions are used to <em>initialize</em> a stream for deflation or inflation, respectively:</p>
<pre><code class="lang-c"><span class="hljs-comment">/*
 * Initializes the internal `z_stream` state
 * for compression at `level`, which indicates
 * scale of speed versuss compression on a 
 * scale from 0-9. Sourced from &lt;zlib.h&gt;.
 */</span>
deflateInit(z_stream, level);

<span class="hljs-comment">/*
 * Initializes the internal `z_stream` state for
 * decompression. Sourced from &lt;zlib.h&gt;.
 */</span>
inflateInit(z_stream);
</code></pre>
<p>The following <code>zlib</code> functions are used to perform the actual deflation and inflation operations:</p>
<pre><code class="lang-c"><span class="hljs-comment">/*
 * Compresses as much data as possible and stops
 * when the input buffer becomes empty or the
 * output buffer becomes full. Sourced from &lt;zlib.h&gt;.
 */</span>
deflate(z_stream, flush);

<span class="hljs-comment">/*
 * Decompresses as much data as possible and stops
 * when the input buffer becomes empty or the
 * output buffer becomes full. Sourced from &lt;zlib.h&gt;.
 */</span>
inflate(z_stream, flush);
</code></pre>
<p>The actual deflation/inflation process is a bit more complex than this and involves setting several parameters of the compression stream, but we won't go into more detail here.</p>
<p>Next, we'll discuss the concept of hash functions and how they are implemented in Git's original code.</p>
<h3 id="heading-hash-functions">Hash Functions</h3>
<p>A hash function is a function that can easily transform an input into a unique output, but makes it very difficult or impossible to reverse that operation. In other words, it is a <strong>one-way function</strong>. It is not possible with today's technology to use the output of a hash function to deduce the input that was used to generate that output.</p>
<p>Git uses a hash function – specifically the SHA-1 hash function – to generate unique identifiers for the files we tell Git to track.</p>
<p>As developers, we make changes to the code files in the codebase we are working on using a text editor, and at some point we tell Git to track those changes. At this point, Git uses those file changes as inputs for the hash function.</p>
<p>The output to the hash function is called a <strong>hash*</strong>.* The hash is a hexadecimal value 40 characters in length, such as <code>47a013e660d408619d894b20806b1d5086aab03b</code>.</p>
<p><img src="https://initialcommit.com/img/initialcommit/figure5.png" alt="Git hash function" width="894" height="462" loading="lazy"></p>
<p><em>Source: https://initialcommit.com/blog/Learn-Git-Guidebook-For-Developers-Chapter-2</em></p>
<p>Git uses these hashes for various purposes that we will see in the following sections.</p>
<h3 id="heading-objects">Objects</h3>
<p>Git uses a simple data model – a structured set of related objects – to implement its functionality. These objects are the nuggets of information that enable Git to track changes to the files of a codebase. The three types of objects that Git uses are:</p>
<ul>
<li><p>Blob</p>
</li>
<li><p>Tree</p>
</li>
<li><p>Commit</p>
</li>
</ul>
<p>Let's discuss each one in turn.</p>
<h4 id="heading-blob">Blob</h4>
<p>A blob is short for a <strong>B</strong>inary <strong>L</strong>arge <strong>OB</strong>ject. When Git is told to track a file using the <code>update-cache &lt;filename.ext&gt;</code> command, (the predecessor to <code>git add</code>), Git creates a new blob using the compressed contents of that file.</p>
<p>Git takes the content of the file, compresses it using the <code>zlib</code> functions we described above, and uses this compressed content as input to the SHA-1 hash function. This creates a 40 character hash that Git uses to identify the blob in question.</p>
<p>Finally, Git saves the blob as a binary file in a special folder called the <strong>object database</strong> (more on this in a minute). The name of the blob file is the generated hash, and the contents of the blob file are the compressed file contents that were added using <code>update-cache</code>.</p>
<h4 id="heading-tree">Tree</h4>
<p>Tree objects are used to link together multiple blobs that are added to Git at once. They are also used to correlate blobs with file names (and other file metadata like permissions), since blobs don't provide any information besides the hash and compressed binary file content.</p>
<p>For example, if two changed files are added using the <code>update-cache</code> command, a tree will be created containing the hashes of those files, along with the file name that each of those blobs corresponds to.</p>
<p>What Git does next is very interesting, so pay attention. Git uses <strong>the content of the tree itself</strong> as input to the SHA-1 hash function, which generates a 40 character hash. This hash is used to identify the tree object, and Git saves this in the same special folder that blobs are saved in – the object database we'll touch on shortly.</p>
<h4 id="heading-commit">Commit</h4>
<p>You're probably more familiar with commit objects than with blobs and trees. A commit represents a set of file changes saved by Git, along with descriptive information about the change such as a commit message, the author's name, and the timestamp of the commit.</p>
<p>In Git's original code, a commit object is the result of running the <code>commit-tree &lt;tree-hash&gt;</code> command. The resulting commit object includes the specified tree object (which remember, represents a collection of file changes via one or more blobs mapped to their file names), and the descriptive information mentioned in the previous paragraph.</p>
<p>Like blobs and trees, Git identifies the commit by hashing its content using the SHA-1 hash function, and saving it in the object database. Importantly, each commit object also contains the hash of its parent commit. In this way, the commits form a chain that Git can use to represent the history of a project.</p>
<h3 id="heading-current-directory-cache-staging-area">Current Directory Cache (Staging Area)</h3>
<p>You probably know Git's staging area as the place your changed files go after using the <code>git add</code> command, patiently waiting to be committed using <code>git commit</code>. But what exactly is the staging area?</p>
<p>In Git's original version, the staging area is called the <strong>current directory cache</strong>. The current directory cache is just a binary file stored in the repository at the path <code>.dircache/index</code>.</p>
<p>As mentioned in the previous section, after changed files are added to Git using the <code>update-cache</code> (<code>git add</code>) command, Git calculates the blob and tree objects associated with those changes. The generated tree object associated with the staged files is added to the <code>index</code> file.</p>
<p>It is called a <strong>cache</strong> because it is just a temporary storage location for the staged changes to reside before being committed. When the user makes a commit by running the <code>commit-tree</code> command, the tree from the current directory cache can be supplied. It also includes other commit information like the commit message for Git to create a new commit object with.</p>
<p>At that point the <code>index</code> file is simply removed to make room for new changes to be staged.</p>
<h3 id="heading-content-addressable-database-object-database">Content Addressable Database (Object Database)</h3>
<p>The object database is Git's primary storage location. This is where all the objects we discussed above – blobs, trees, and commits – are stored. In Git's original version, the object database is simply a directory at the path <code>.dircache/objects/</code>.</p>
<p>When Git creates objects through operations such as <code>update-cache</code>, <code>write-tree</code>, and <code>commit-tree</code>, (the predecessors of <code>git add</code> and <code>git commit</code>), these objects are compressed, hashed, and stored in the object database.</p>
<p>The name of each object is the hash of its content, hence why the object database is also called a <strong>content addressable database*</strong>.* Each piece of content (blob, tree, or commit) is stored and retrieved based on an identifier generated from the content itself.</p>
<p>The modern version of Git works very much the same way. The difference is that storage formats have been optimized to use more efficient methods (especially related to data transfer over networks), but the basic principles are the same.</p>
<h2 id="heading-summary">Summary</h2>
<p>In this article, we discussed the original version of Git's code in order to highlight how reading existing code can help boost your coding skills.</p>
<p>We covered the reasons Git is a great project to learn from in this way, how to access Git's code, and reviewed some related C programming concepts. Finally, we provided an overview of Git's original codebase structure and dove into some concepts that Git's code relies on.</p>
<h2 id="heading-next-steps">Next Steps</h2>
<p>If you're interested in learning more about Git's code, <a target="_blank" href="https://initialcommit.com/store/baby-git-guidebook-for-developers">we wrote a guidebook you can check out here</a>. This book dives into Git's original C code in detail and directly explains how the code works.</p>
<p>I encourage any and all developers to explore the open-source community to try and find quality projects that interest you. Those projects will have codebases that you can clone down in a matter of minutes.</p>
<p>Take some time to poke around the code, and you might learn something you never expected to find.</p>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
