<?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" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Nicolas Barlatier on Medium]]></title>
        <description><![CDATA[Stories by Nicolas Barlatier on Medium]]></description>
        <link>https://medium.com/@barlatiernicolas?source=rss-4bd015257f0a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*_ntuuTvBPRH4eCAe-gkufQ.jpeg</url>
            <title>Stories by Nicolas Barlatier on Medium</title>
            <link>https://medium.com/@barlatiernicolas?source=rss-4bd015257f0a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 10:11:56 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@barlatiernicolas/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Master Git Like a Pro: The Complete Command-Line Workflow Guide (Part 1)]]></title>
            <link>https://medium.com/@barlatiernicolas/master-git-like-a-pro-the-complete-command-line-workflow-guide-2a62b98252ed?source=rss-4bd015257f0a------2</link>
            <guid isPermaLink="false">https://medium.com/p/2a62b98252ed</guid>
            <dc:creator><![CDATA[Nicolas Barlatier]]></dc:creator>
            <pubDate>Sun, 08 Nov 2026 14:07:57 GMT</pubDate>
            <atom:updated>2026-12-01T16:46:49.071Z</atom:updated>
            <content:encoded><![CDATA[<p>The local workflow, from git init to reflog recovery</p><figure><img alt="Cover: Master Git Like a Pro, Part 1, local workflow. A small commit graph with HEAD and master, and terminal snippets of git reset and git reflog." src="https://cdn-images-1.medium.com/max/1024/1*l294Ps75WNGE0TTolh5ghg.png" /></figure><p>Note: I wrote this tutorial and ran every command myself. I used an AI assistant for the diagrams.</p><p><strong>Table of Contents</strong></p><ul><li><a href="https://medium.com/@barlatiernicolas/master-git-like-a-pro-the-complete-command-line-workflow-guide-2a62b98252ed#3646">Introduction</a> — why learn Git properly</li><li><a href="https://medium.com/@barlatiernicolas/master-git-like-a-pro-the-complete-command-line-workflow-guide-2a62b98252ed#f6c3">Sample Project</a> — the demo repo used throughout</li><li><a href="https://medium.com/@barlatiernicolas/master-git-like-a-pro-the-complete-command-line-workflow-guide-2a62b98252ed#bdf2">git help</a> — porcelain vs plumbing commands</li><li><a href="https://medium.com/@barlatiernicolas/master-git-like-a-pro-the-complete-command-line-workflow-guide-2a62b98252ed#74d4">Main Porcelain Commands</a> — the everyday commands at a glance</li><li><a href="https://medium.com/@barlatiernicolas/master-git-like-a-pro-the-complete-command-line-workflow-guide-2a62b98252ed#ac93">git init</a> — create the local repository</li><li><a href="https://medium.com/@barlatiernicolas/master-git-like-a-pro-the-complete-command-line-workflow-guide-2a62b98252ed#91f7">git branch</a> — why a new repo shows no branch</li><li><a href="https://medium.com/@barlatiernicolas/master-git-like-a-pro-the-complete-command-line-workflow-guide-2a62b98252ed#0a37">git status</a> — read the state of your files</li><li><a href="https://medium.com/@barlatiernicolas/master-git-like-a-pro-the-complete-command-line-workflow-guide-2a62b98252ed#4680">Git Workflow</a> — working tree, staging area, commit</li><li><a href="https://medium.com/@barlatiernicolas/master-git-like-a-pro-the-complete-command-line-workflow-guide-2a62b98252ed#fe9e">Track files</a> — tracked vs untracked</li><li><a href="https://medium.com/@barlatiernicolas/master-git-like-a-pro-the-complete-command-line-workflow-guide-2a62b98252ed#7ecf">git add</a> — stage new, modified and deleted files</li><li><a href="https://medium.com/@barlatiernicolas/master-git-like-a-pro-the-complete-command-line-workflow-guide-2a62b98252ed#19e9">Reset: going back</a> — soft, mixed, hard, and unstaging</li><li><a href="https://medium.com/@barlatiernicolas/master-git-like-a-pro-the-complete-command-line-workflow-guide-2a62b98252ed#d215">HEAD</a> — where you are: attached, detached, relative refs</li><li><a href="https://medium.com/@barlatiernicolas/master-git-like-a-pro-the-complete-command-line-workflow-guide-2a62b98252ed#9ea2">git switch</a> — moving HEAD, and committing in detached mode</li><li><a href="https://medium.com/@barlatiernicolas/master-git-like-a-pro-the-complete-command-line-workflow-guide-2a62b98252ed#59b8">Reflog</a> — recover “lost” commits</li><li><a href="https://medium.com/@barlatiernicolas/master-git-like-a-pro-the-complete-command-line-workflow-guide-2a62b98252ed#89e5">git update-ref</a> — a teaser for Part 2</li></ul><h3><strong>Introduction</strong></h3><p>Most developers use a fraction of Git: add, commit, push, pull, and maybe merge on a brave day. This series goes further. Part 1 (this article) builds the mental model: the three areas, staging, reset, HEAD, detached HEAD and reflog recovery. Part 2 covers merging and resolving conflicts, working with remotes (clone, fetch, pull, push), interactive rebase, bisect for hunting regressions, worktrees for parallel branches and Git’s plumbing: the workflows that separate “I use Git” from “I understand Git.”</p><p>We will use no GUI, no shortcuts, just the terminal and the commands that make version control click.</p><p><strong>Note: this part uses Git locally only.</strong> There is no remote, no GitHub, no push or pull: every command runs against the repository on your machine. Working with remotes (clone, fetch, pull, push) comes in Part 2.</p><p>Remember, version control is one of the few foundational engineering skills that AI will not use without our approval. Understanding what’s actually happening in your repo — not just which button to click — stays valuable no matter how much of the coding itself gets automated.</p><h3>Sample Project</h3><p>Here’s the demo project we’ll use throughout:</p><pre>git-tutorial-demo/<br>├── .gitignore<br>├── README.md<br>├── src/<br>│ ├── index.js<br>│ └── utils.js<br>├── tests/<br>│ └── utils.test.js<br>└── docs/<br> └── notes.md</pre><p>README.md contains:</p><pre># Git Tutorial Demo<br>A tiny project used to demonstrate Git workflows from init to advanced commands.</pre><p>.gitignore</p><pre>node_modules/<br>*.log<br>.env</pre><p>src/index.js</p><pre>const { add } = require(&#39;./utils&#39;);<br><br>console.log(add(2, 3));</pre><p>src/utils.js</p><pre><br>function add(a, b) {<br>  return a + b;<br>}<br><br>module.exports = { add };</pre><p>tests/utils.test.js</p><pre>const { add } = require(&#39;../src/utils&#39;);<br><br>console.log(add(1, 1) === 2 ? &#39;PASS&#39; : &#39;FAIL&#39;);<br></pre><pre>❯ tree /f /a C:\tutorial\git-tutorial-demo<br>C:\TUTORIAL\GIT-TUTORIAL-DEMO<br>|   .gitignore<br>|   README.md<br>|<br>+---docs<br>|       notes.md<br>|<br>+---src<br>|       index.js<br>|       utils.js<br>|<br>\---tests<br>        utils.test.js</pre><p>First, Git has built-in help. To list every command, run the following:</p><h3>git help</h3><pre>C:\tutorial\git-tutorial-demo&gt;git help -a<br>See &#39;git help &lt;command&gt;&#39; to read about a specific subcommand<br><br>Main Porcelain Commands<br>   add                     Add file contents to the index<br>   am                      Apply a series of patches from a mailbox<br>   archive                 Create an archive of files from a named tree<br>   backfill                Download missing objects in a partial clone<br>   bisect                  Use binary search to find the commit that introduced a bug<br>   branch                  List, create, or delete branches<br>   bundle                  Move objects and refs by archive<br>   checkout                Switch branches or restore working tree files<br>   cherry-pick             Apply the changes introduced by some existing commits<br>   citool                  Graphical alternative to git-commit<br>   clean                   Remove untracked files from the working tree<br>   clone                   Clone a repository into a new directory<br>   commit                  Record changes to the repository<br>   describe                Give an object a human readable name based on an available ref<br>   diff                    Show changes between commits, commit and working tree, etc<br>   fetch                   Download objects and refs from another repository<br>   format-patch            Prepare patches for e-mail submission<br>   gc                      Cleanup unnecessary files and optimize the local repository<br>   gitk                    The Git repository browser<br>   grep                    Print lines matching a pattern<br>   gui                     A portable graphical interface to Git<br>   history                 EXPERIMENTAL: Rewrite history<br>   init                    Create an empty Git repository or reinitialize an existing one<br>   log                     Show commit logs<br>   maintenance             Run tasks to optimize Git repository data<br>   merge                   Join two or more development histories together<br>   mv                      Move or rename a file, a directory, or a symlink<br>   notes                   Add or inspect object notes<br>   pull                    Fetch from and integrate with another repository or a local branch<br>   push                    Update remote refs along with associated objects<br>   range-diff              Compare two commit ranges (e.g. two versions of a branch)<br>   rebase                  Reapply commits on top of another base tip<br>   reset                   Set `HEAD` or the index to a known state<br>   restore                 Restore working tree files<br>   revert                  Revert some existing commits<br>   rm                      Remove files from the working tree and from the index<br>   scalar                  A tool for managing large Git repositories<br>   shortlog                Summarize `git log` output<br>   show                    Show various types of objects<br>   sparse-checkout         Reduce your working tree to a subset of tracked files<br>   stash                   Stash the changes in a dirty working directory away<br>   status                  Show the working tree status<br>   submodule               Initialize, update or inspect submodules<br>   survey                  EXPERIMENTAL: Measure various repository dimensions of scale<br>   switch                  Switch branches<br>   tag                     Create, list, delete or verify tags<br>   worktree                Manage multiple working trees<br><br>Ancillary Commands / Manipulators<br>   config                  Get and set repository or global options<br>   fast-export             Git data exporter<br>   fast-import             Backend for fast Git data importers<br>   filter-branch           Rewrite branches<br>   mergetool               Run merge conflict resolution tools to resolve merge conflicts<br>   pack-refs               Pack heads and tags for efficient repository access<br>   prune                   Prune all unreachable objects from the object database<br>   reflog                  Manage reflog information<br>   refs                    Low-level access to refs<br>   remote                  Manage set of tracked repositories<br>   repack                  Pack unpacked objects in a repository<br>   replace                 Create, list, delete refs to replace objects<br><br>Ancillary Commands / Interrogators<br>   annotate                Annotate file lines with commit information<br>   blame                   Show what revision and author last modified each line of a file<br>   bugreport               Collect information for user to file a bug report<br>   count-objects           Count unpacked number of objects and their disk consumption<br>   diagnose                Generate a zip archive of diagnostic information<br>   difftool                Show changes using common diff tools<br>   fsck                    Verifies the connectivity and validity of the objects in the database<br>   gitweb                  Git web interface (web frontend to Git repositories)<br>   help                    Display help information about Git<br>   instaweb                Instantly browse your working repository in gitweb<br>   merge-tree              Perform merge without touching index or working tree<br>   rerere                  Reuse recorded resolution of conflicted merges<br>   show-branch             Show branches and their commits<br>   verify-commit           Check the GPG signature of commits<br>   verify-tag              Check the GPG signature of tags<br>   version                 Display version information about Git<br>   whatchanged             Show logs with differences each commit introduces<br><br>Interacting with Others<br>   archimport              Import a GNU Arch repository into Git<br>   cvsexportcommit         Export a single commit to a CVS checkout<br>   cvsimport               Salvage your data out of another SCM people love to hate<br>   cvsserver               A CVS server emulator for Git<br>   imap-send               Send a collection of patches from stdin to an IMAP folder<br>   p4                      Import from and submit to Perforce repositories<br>   quiltimport             Applies a quilt patchset onto the current branch<br>   request-pull            Generates a summary of pending changes<br>   send-email              Send a collection of patches as emails<br>   svn                     Bidirectional operation between a Subversion repository and Git<br><br>Low-level Commands / Manipulators<br>   apply                   Apply a patch to files and/or to the index<br>   checkout-index          Copy files from the index to the working tree<br>   commit-graph            Write and verify Git commit-graph files<br>   commit-tree             Create a new commit object<br>   hash-object             Compute object ID and optionally create an object from a file<br>   index-pack              Build pack index file for an existing packed archive<br>   merge-file              Run a three-way file merge<br>   merge-index             Run a merge for files needing merging<br>   mktag                   Creates a tag object with extra validation<br>   mktree                  Build a tree-object from ls-tree formatted text<br>   multi-pack-index        Write and verify multi-pack-indexes<br>   pack-objects            Create a packed archive of objects<br>   prune-packed            Remove extra objects that are already in pack files<br>   read-tree               Reads tree information into the index<br>   replay                  EXPERIMENTAL: Replay commits on a new base, works with bare repos too<br>   symbolic-ref            Read, modify and delete symbolic refs<br>   unpack-objects          Unpack objects from a packed archive<br>   update-index            Register file contents in the working tree to the index<br>   update-ref              Update the object name stored in a ref safely<br>   write-tree              Create a tree object from the current index<br><br>Low-level Commands / Interrogators<br>   cat-file                Provide contents or details of repository objects<br>   cherry                  Find commits yet to be applied to upstream<br>   diff-files              Compares files in the working tree and the index<br>   diff-index              Compare a tree to the working tree or index<br>   diff-pairs              Compare the content and mode of provided blob pairs<br>   diff-tree               Compares the content and mode of blobs found via two tree objects<br>   for-each-ref            Output information on each ref<br>   for-each-repo           Run a Git command on a list of repositories<br>   format-rev              EXPERIMENTAL: Pretty format revisions on demand<br>   get-tar-commit-id       Extract commit ID from an archive created using git-archive<br>   last-modified           EXPERIMENTAL: Show when files were last modified<br>   ls-files                Show information about files in the index and the working tree<br>   ls-remote               List references in a remote repository<br>   ls-tree                 List the contents of a tree object<br>   merge-base              Find as good common ancestors as possible for a merge<br>   name-rev                Find symbolic names for given revs<br>   pack-redundant          Find redundant pack files<br>   repo                    Retrieve information about the repository<br>   rev-list                Lists commit objects in reverse chronological order<br>   rev-parse               Pick out and massage parameters<br>   show-index              Show packed archive index<br>   show-ref                List references in a local repository<br>   unpack-file             Creates a temporary file with a blob&#39;s contents<br>   var                     Show a Git logical variable<br>   verify-pack             Validate packed Git archive files<br><br>Low-level Commands / Syncing Repositories<br>   daemon                  A really simple server for Git repositories<br>   fetch-pack              Receive missing objects from another repository<br>   http-backend            Server side implementation of Git over HTTP<br>   send-pack               Push objects over Git protocol to another repository<br>   update-server-info      Update auxiliary info file to help dumb servers<br><br>Low-level Commands / Internal Helpers<br>   check-attr              Display gitattributes information<br>   check-ignore            Debug gitignore / exclude files<br>   check-mailmap           Show canonical names and email addresses of contacts<br>   check-ref-format        Ensures that a reference name is well formed<br>   column                  Display data in columns<br>   credential              Retrieve and store user credentials<br>   credential-cache        Helper to temporarily store passwords in memory<br>   credential-store        Helper to store credentials on disk<br>   fmt-merge-msg           Produce a merge commit message<br>   hook                    Run Git hooks<br>   interpret-trailers      Add or parse structured information in commit messages<br>   mailinfo                Extracts patch and authorship from a single e-mail message<br>   mailsplit               Simple UNIX mbox splitter program<br>   merge-one-file          The standard helper program to use with git-merge-index<br>   patch-id                Compute unique IDs for patches<br>   sh-i18n                 Git&#39;s i18n setup code for shell scripts<br>   sh-setup                Common Git shell script setup code<br>   stripspace              Remove unnecessary whitespace<br>   url-parse               Parse and extract git URL components<br><br>User-facing repository, command and file interfaces<br>   attributes              Defining attributes per path<br>   cli                     Git command-line interface and conventions<br>   hooks                   Hooks used by Git<br>   ignore                  Specifies intentionally untracked files to ignore<br>   mailmap                 Map author/committer names and/or E-Mail addresses<br>   modules                 Defining submodule properties<br>   repository-layout       Git Repository Layout<br>   revisions               Specifying revisions and ranges for Git<br><br>Developer-facing file formats, protocols and other interfaces<br>   format-bundle           The bundle file format<br>   format-chunk            Chunk-based file formats<br>   format-commit-graph     Git commit-graph format<br>   format-index            Git index format<br>   format-pack             Git pack format<br>   format-signature        Git cryptographic signature formats<br>   protocol-capabilities   Protocol v0 and v1 capabilities<br>   protocol-common         Things common to various protocols<br>   protocol-http           Git HTTP-based protocols<br>   protocol-pack           How packs are transferred over-the-wire<br>   protocol-v2             Git Wire Protocol, Version 2<br><br>External commands<br>   askpass<br>   askyesno<br>   credential-helper-selector<br>   credential-manager<br>   lfs<br>   update-git-for-windows</pre><p>Git groups its commands by role, but in practice there are two families: porcelain and plumbing.</p><p>The names come from a toilet analogy:</p><ul><li>Porcelain is the clean, user-facing part. These are the high-level commands you type every day.</li><li>Plumbing is the hidden pipework underneath. These are low-level commands that work directly on Git’s internals, mostly for scripts and tools.</li></ul><p><strong>Most porcelain commands are built by combining plumbing commands.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OPqdgkgj8eIa0ouz0IcPMw.png" /><figcaption>Porcelain commands are built from plumbing: what add, commit, branch and log really run underneath.</figcaption></figure><p>Let’s explore the porcelain commands first.</p><h3>Main Porcelain Commands</h3><pre>Area            Commands<br>--------------  ------------------------------------------------------------<br>Start           git init, git clone<br>Snapshot        git add, git status, git diff, git commit, git rm, git mv,<br>                git restore<br>Branch &amp; merge  git branch, git switch, git checkout, git merge, git rebase,<br>                git tag, git stash<br>History         git log, git show, git blame, git reflog<br>Share           git fetch, git pull, git push, git remote<br>Undo            git reset, git revert, git cherry-pick</pre><p>Plumbing equivalents (for comparison)</p><pre>git add file  git hash-object -w file + git update-index --add file<br>git commit    git write-tree + git commit-tree + git update-ref<br>git log       git rev-list + git cat-file<br>git branch new  git update-ref refs/heads/new HEAD</pre><h3>git init</h3><p>Now let’s create a local git repository at the project root.</p><pre>C:\tutorial\git-tutorial-demo<br>❯ git init<br>Initialized empty Git repository in C:/tutorial/git-tutorial-demo/.git/<br><br>❯ tree .git<br>C:\TUTORIAL\GIT-TUTORIAL-DEMO\.GIT<br>├───hooks<br>├───info<br>├───objects<br>│   ├───info<br>│   └───pack<br>└───refs<br>    ├───heads<br>    └───tags</pre><p>We see that the git init command adds a hidden directory: .git.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XWFPr0EmiE53-128zx6maQ.png" /><figcaption>Inside .git/: HEAD names a branch, a branch holds a hash. Unborn, attached and detached HEAD side by side.</figcaption></figure><p>This .git folder is actually the local repository: it holds the history, branches and settings. Everything outside is the working tree.</p><p>For now, we only have an unborn default branch: master or main, depending on your config. I call it unborn because there is no commit yet.</p><p>What does that mean? It means the HEAD pointer already names a branch:</p><pre>git-tutorial-demo on  master [?]<br>❯ type .git\head<br>ref: refs/heads/master</pre><p>(or main, depending on your init.defaultBranch setting)</p><p>But the file .git\refs\heads\master doesn’t exist yet. A branch is just a pointer to a commit, and there are no commits yet. So the branch has a name but no commit to point to, which is why it’s called “unborn”.</p><pre>git-tutorial-demo on  master [?]<br>❯ ls .\.git\refs\heads\<br><br>git-tutorial-demo on  master [?]<br>❯</pre><p>.git\refs\heads is empty. Normally it contains all the branches.</p><p>Example when we have branches:</p><pre>.git\refs\heads on  pre-prod [$⇣]<br>❯ ls -l<br>total 6<br>drwxr-xr-x 1 xxx 1049089  0 Oct 22 14:04 feature<br>-rw-r--r-- 1 xxx 1049089 41 Oct 28 17:27 pre-prod<br>-rw-r--r-- 1 xxx 1049089 41 Oct 22 14:04 prod</pre><p>We have here 2 branches and one directory which has further branches (created by git flow)</p><p>A branch without any commit is an unborn branch.</p><h3>git branch</h3><p>Technically, HEAD is just a simple text file located inside your hidden Git folder at .git/HEAD</p><p>Our project is now initialized to use Git locally. Let’s check for the branches. As we said, there are none: a branch needs a commit, it is logical as the branch needs the commit id.</p><pre>C:\tutorial\git-tutorial-demo&gt;git branch</pre><h3>git status</h3><p>When we run:</p><pre>C:\tutorial\git-tutorial-demo&gt;git status<br>On branch master<br><br>No commits yet<br><br>Untracked files:<br>  (use &quot;git add &lt;file&gt;...&quot; to include in what will be committed)<br>        .gitignore<br>        README.md<br>        docs/<br>        src/<br>        tests/<br><br>nothing added to commit but untracked files present (use &quot;git add&quot; to track)</pre><ul><li>so we are on the branch master and no commit exist yet. As long as there is not commit and no branch history <strong>we won’t see the master branch</strong>.</li><li><strong>Git only creates a real <em>branch ref</em></strong><em> o</em>nce the first commit is made.</li><li>Right after git init, <strong>HEAD points to refs/heads/master</strong> but that ref doesn’t exist as an actual object until you commit, so there’s nothing for git branch to list</li></ul><p>When we look at</p><pre>cat .git/HEAD<br><br>ref: refs/heads/master<br><br><br>C:\tutorial\git-tutorial-demo&gt;git log<br>fatal: your current branch &#39;master&#39; does not have any commits yet</pre><p>But Let’s see how git branch works</p><pre>C:\tutorial\git-tutorial-demo&gt;git branch -h<br>usage: git branch [&lt;options&gt;] [-r | -a] [--merged] [--no-merged]<br>   or: git branch [&lt;options&gt;] [-f] [--recurse-submodules] &lt;branch-name&gt; [&lt;start-point&gt;]<br>   or: git branch [&lt;options&gt;] [-l] [&lt;pattern&gt;...]<br>   or: git branch [&lt;options&gt;] [-r] (-d | -D) &lt;branch-name&gt;...<br>   or: git branch [&lt;options&gt;] (-m | -M) [&lt;old-branch&gt;] &lt;new-branch&gt;<br>   or: git branch [&lt;options&gt;] (-c | -C) [&lt;old-branch&gt;] &lt;new-branch&gt;<br>   or: git branch [&lt;options&gt;] [-r | -a] [--points-at]<br>   or: git branch [&lt;options&gt;] [-r | -a] [--format]<br><br>Generic options<br>    -v, --[no-]verbose    show hash and subject, give twice for upstream branch<br>    -q, --[no-]quiet      suppress informational messages<br>    -t, --[no-]track[=(direct|inherit)]<br>                          set branch tracking configuration<br>    -u, --[no-]set-upstream-to &lt;upstream&gt;<br>                          change the upstream info<br>    --[no-]unset-upstream unset the upstream info<br>    --[no-]color[=&lt;when&gt;] use colored output<br>    -r, --remotes         act on remote-tracking branches<br>    --contains &lt;commit&gt;   print only branches that contain the commit<br>    --no-contains &lt;commit&gt;<br>                          print only branches that don&#39;t contain the commit<br>    --[no-]abbrev[=&lt;n&gt;]   use &lt;n&gt; digits to display object names<br><br>Specific git-branch actions:<br>    -a, --all             list both remote-tracking and local branches<br>    -d, --[no-]delete     delete fully merged branch<br>    -D                    delete branch (even if not merged)<br>    -m, --[no-]move       move/rename a branch and its reflog<br>    -M                    move/rename a branch, even if target exists<br>    --[no-]omit-empty     do not output a newline after empty formatted refs<br>    -c, --[no-]copy       copy a branch and its reflog<br>    -C                    copy a branch, even if target exists<br>    -l, --[no-]list       list branch names<br>    --[no-]show-current   show current branch name<br>    --[no-]create-reflog  create the branch&#39;s reflog<br>    --[no-]edit-description<br>                          edit the description for the branch<br>    -f, --[no-]force      force creation, move/rename, deletion<br>    --merged &lt;commit&gt;     print only branches that are merged<br>    --no-merged &lt;commit&gt;  print only branches that are not merged<br>    --[no-]column[=&lt;style&gt;]<br>                          list branches in columns<br>    --[no-]sort &lt;key&gt;     field name to sort on<br>    --[no-]points-at &lt;object&gt;<br>                          print only branches of the object<br>    -i, --[no-]ignore-case<br>                          sorting and filtering are case insensitive<br>    --[no-]recurse-submodules<br>                          recurse through submodules<br>    --[no-]format &lt;format&gt;<br>                          format to use for the output</pre><p>Let’s run</p><pre>git-tutorial-demo on  master [?]<br>❯ git branch --show-current<br>master</pre><p>Explanation:</p><p><strong>git branch (plain list mode</strong>) looks at<strong> refs/heads/</strong> <br><strong>It lists branches by reading actual refs under refs/heads/. <br></strong>With zero commits, no such ref exists yet — so the list is empty.</p><p><strong>git branch --show-current</strong> doesn’t look at refs/heads/; <br><strong>it reads the symbolic ref that HEAD points to</strong> (.git/HEAD → ref: refs/heads/master) and just prints that name, regardless of whether it resolves to a real commit yet.</p><pre>git-tutorial-demo on  master [?]<br>❯ cat .git/HEAD<br>ref: refs/heads/master</pre><p>So without any commit: git branch → empty,</p><p>but git branch --show-current → master (it actually shows where HEAD points to; in detached mode it print nothing).</p><p>Sources:<br>- <a href="https://git-scm.com/docs/git-symbolic-ref">https://git-scm.com/docs/git-symbolic-ref</a><br>- <a href="https://adamj.eu/tech/2023/08/20/git-output-just-current-branch-name/">https://adamj.eu/tech/2023/08/20/git-output-just-current-branch-name/</a></p><p>OK, now let’s see how check the status in Git</p><pre>C:\tutorial\git-tutorial-demo&gt;git status<br>On branch master<br><br>No commits yet<br><br>Untracked files:<br>  (use &quot;git add &lt;file&gt;...&quot; to include in what will be committed)<br>        .gitignore<br>        README.md<br>        docs/<br>        src/<br>        tests/<br><br>nothing added to commit but untracked files present (use &quot;git add&quot; to track)</pre><p>Git detects that all the files in the current directory are untracked and nothing has been added to commit.</p><h3><strong>Git Workflow</strong></h3><p>In git we have a three-step workflow:</p><p><strong>working tree</strong> =&gt; <strong>staging area </strong>=&gt; <strong>Commit</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ojI8DYe5cjvxjXMkDusuSg.png" /><figcaption>Git’s three areas, and the commands that move changes between them.</figcaption></figure><p>Each stage is a distinct snapshot:</p><p><strong>git diff without any option compares working tree vs. staging area</strong></p><p><strong>git diff --staged compares staging area vs. last commit.</strong></p><p>We need to understand in git the difference between <strong>tracked </strong>and <strong>untracked</strong> files</p><p>When an element has <strong>never been committed or staged</strong>, Git considers it untracked.</p><p>Let’s check</p><pre>C:\tutorial\git-tutorial-demo&gt;git status<br>On branch master<br><br>No commits yet<br><br>Untracked files:<br>  (use &quot;git add &lt;file&gt;...&quot; to include in what will be committed)<br>        .gitignore<br>        README.md<br>        docs/<br>        src/<br>        tests/<br><br>nothing added to commit but untracked files present (use &quot;git add&quot; to track)</pre><p>All our files are untracked.</p><p>Let’s see a more concise way:</p><pre>C:\tutorial\git-tutorial-demo&gt;git status -s<br>?? .gitignore<br>?? README.md<br>?? docs/<br>?? src/<br>?? tests/</pre><p>We see two ??</p><ul><li>the first ? is the status of the file in the index</li><li>the second ? is the status in the working tree.</li></ul><p>? means the file is unknown to git: untracked.</p><p>The diagram below shows the file lifecycle and the matching git status codes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ev5D-d0xF9DxuWiXjj8XRw.png" /><figcaption>The four states of a file, and how to read the two-letter code of git status -s.</figcaption></figure><h3>Track files</h3><p>Let’s make Git track README.md by adding it to the index.</p><h3>git add</h3><p>The command add calls the tool git-add to add file contents to the index.<br>The “index” (also known as the “staging area”) is what you use to prepare the contents of the next commit.<br>When you run git commit without any other arguments, it will only commit staged changes.<br>You can also add only part of your changes to a file with git add -p (patches). This command can be performed multiple times before a commit.<br>The git add command will not add ignored files by default. You can use the --force option to add ignored files.</p><p>We need to master the command: git add</p><pre>C:\tutorial\git-tutorial-demo&gt;git add -h<br>usage: git add [&lt;options&gt;] [--] &lt;pathspec&gt;...<br><br>    -n, --[no-]dry-run    dry run<br>    -v, --[no-]verbose    be verbose<br><br>    -i, --[no-]interactive<br>                          interactive picking<br>    -p, --[no-]patch      select hunks interactively<br>    --[no-]auto-advance   auto advance to the next file when selecting hunks interactively<br>    -U, --unified &lt;n&gt;     generate diffs with &lt;n&gt; lines context<br>    --inter-hunk-context &lt;n&gt;<br>                          show context between diff hunks up to the specified number of lines<br>    -e, --[no-]edit       edit current diff and apply<br>    -f, --[no-]force      allow adding otherwise ignored files<br>    -u, --[no-]update     update tracked files<br>    --[no-]renormalize    renormalize EOL of tracked files (implies -u)<br>    -N, --[no-]intent-to-add<br>                          record only the fact that the path will be added later<br>    -A, --[no-]all        add changes from all tracked and untracked files<br>    --[no-]ignore-removal ignore paths removed in the working tree (same as --no-all)<br>    --[no-]refresh        don&#39;t add, only refresh the index<br>    --[no-]ignore-errors  just skip files which cannot be added because of errors<br>    --[no-]ignore-missing check if - even missing - files are ignored in dry run<br>    --[no-]sparse         allow updating entries outside of the sparse-checkout cone<br>    --[no-]chmod (+|-)x   override the executable bit of the listed files<br>    --[no-]pathspec-from-file &lt;file&gt;<br>                          read pathspec from file<br>    --[no-]pathspec-file-nul<br>                          with --pathspec-from-file, pathspec elements are separated with NUL character</pre><p>We will see the <strong>git add has 3 functions</strong>:</p><ul><li><strong>Start tracking a new file</strong></li><li><strong>Stage modifications to an existing tracked file</strong>, it is like moving Working Tree → Index</li><li><strong>Stage a deletion</strong></li></ul><p>git add updates the <strong>index</strong> so that it matches the current state of the working tree for the specified path.</p><p>Therefore it can stage:</p><ul><li><strong>New files</strong> ✅</li><li><strong>Modified files</strong> ✅</li><li><strong>Deleted files</strong> ✅</li></ul><p>In our case, we just need to do the following we can use the — dry-run option to see what would be added, without adding anything:</p><pre><br>git-tutorial-demo on  master [?]<br>❯ git add --dry-run .<br>add &#39;.gitignore&#39;<br>add &#39;README.md&#39;<br>add &#39;docs/notes.md&#39;<br>add &#39;src/index.js&#39;<br>add &#39;src/utils.js&#39;<br>add &#39;tests/utils.test.js&#39;</pre><p><strong>The . in: <em>git add .</em></strong></p><p>The dot means “the current directory”. <br>It isn’t special to Git: it is the standard path for “this folder”, and it works the same in cd ., dir . and code ..</p><p>So git add . means: stage everything in this folder and all its subfolders.</p><p>That includes:</p><p>- new files (untracked)<br>- modified files<br>- deleted files</p><p>Files that match .gitignore are skipped.</p><p>The dot depends on where you are</p><blockquote>cd C:\tutorial\git-tutorial-demo<br>git add . # stages the whole project</blockquote><blockquote>cd src<br>git add . # stages only src\ and its subfolders</blockquote><p>You can also use the option -A to add everything:</p><pre>git-tutorial-demo on  master [?]<br>❯ git add --dry-run .<br>add &#39;.gitignore&#39;<br>add &#39;README.md&#39;<br>add &#39;docs/notes.md&#39;<br>add &#39;src/index.js&#39;<br>add &#39;src/utils.js&#39;<br>add &#39;tests/utils.test.js&#39;<br><br>❯ git add -A<br>warning: in the working copy of &#39;.gitignore&#39;, LF will be replaced by CRLF the next time Git touches it<br>warning: in the working copy of &#39;README.md&#39;, LF will be replaced by CRLF the next time Git touches it<br>warning: in the working copy of &#39;docs/notes.md&#39;, LF will be replaced by CRLF the next time Git touches it<br>warning: in the working copy of &#39;src/index.js&#39;, LF will be replaced by CRLF the next time Git touches it<br>warning: in the working copy of &#39;src/utils.js&#39;, LF will be replaced by CRLF the next time Git touches it<br>warning: in the working copy of &#39;tests/utils.test.js&#39;, LF will be replaced by CRLF the next time Git touches it<br><br>git-tutorial-demo on  master [+]<br>❯ git status -s<br>A  .gitignore<br>A  README.md<br>A  docs/notes.md<br>A  src/index.js<br>A  src/utils.js<br>A  tests/utils.test.js</pre><p>So we did the following:</p><p>Untracked =&gt; Tracked in the Index with the status A (added)</p><p>We can check with the command git status -s</p><pre><br>git-tutorial-demo on  master [+]<br>❯ git status -s<br>A  .gitignore<br>A  .serena/.gitignore<br>A  .serena/project.yml<br>A  README.md<br>A  docs/notes.md<br>A  src/index.js<br>A  src/utils.js<br>A  tests/utils.test.js</pre><h3>Reset: going back</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZFQtgOZpwEexNGFqe6fAzA.png" /><figcaption>The three git reset modes, soft, mixed and hard: same branch move, different impact on the index and working tree.</figcaption></figure><p>Memory Trick:</p><p>--soft Only move back the branch</p><p>--mixed Move back the branch + Index</p><p>--hard Move back the branch + Index + Working Tree</p><p>We can go back <strong>Tracked in the Index =&gt; Untracked with the command git reset</strong></p><p>To go back from the staged status to the untracked status we just need the following command <strong><em>git reset</em></strong></p><pre>❯ cd C:\tutorial\git-tutorial-demo\<br><br>git-tutorial-demo on  master [?]<br>❯ git add -A<br>warning: in the working copy of &#39;.gitignore&#39;, LF will be replaced by CRLF the next time Git touches it<br>warning: in the working copy of &#39;README.md&#39;, LF will be replaced by CRLF the next time Git touches it<br>warning: in the working copy of &#39;docs/notes.md&#39;, LF will be replaced by CRLF the next time Git touches it<br>warning: in the working copy of &#39;src/index.js&#39;, LF will be replaced by CRLF the next time Git touches it<br>warning: in the working copy of &#39;src/utils.js&#39;, LF will be replaced by CRLF the next time Git touches it<br>warning: in the working copy of &#39;tests/utils.test.js&#39;, LF will be replaced by CRLF the next time Git touches it<br><br>git-tutorial-demo on  master [+]<br>❯ git status -s<br>A  .gitignore<br>A  .serena/.gitignore<br>A  .serena/project.yml<br>A  README.md<br>A  docs/notes.md<br>A  src/index.js<br>A  src/utils.js<br>A  tests/utils.test.js<br><br>git-tutorial-demo on  master [+]<br>❯ git reset<br><br>git-tutorial-demo on  master [?]<br>❯ git status -s<br>?? .gitignore<br>?? .serena/<br>?? README.md<br>?? docs/<br>?? src/<br>?? tests/</pre><p>In fact when we run Plain git reset we do:</p><blockquote>git reset --mixed HEAD</blockquote><p>Git first determines what HEAD refers to.<br>The option --mixed is the default reset mode, and Git updates the index (staging area) to be identical to the commit of the HEAD.<br><strong>It unstages everything and touches nothing else.</strong><br>Branch / HEAD: it doesn’t move. It “resets” to HEAD, which is where you already are.<br>Index (staging area): it is reset to match the last commit, so everything you staged with git add becomes unstaged again.</p><p>let’s say we have A-B-C</p><p>We reset to B:<br>- Hard: HEAD, index, working tree are reset <strong>HEAD=B Index=B Worktree=B</strong><br>- Mixed (makes the index identical to the commit): HEAD, index are reset <strong>HEAD=B Index=B Worktree=C</strong><br>- Soft: HEAD is reset <strong>HEAD=B Index=C Worktree=C</strong></p><p><strong><em>The mixed option is like unstage all the files (only its effect)</em></strong></p><p><strong>The index is empty here because nothing has been staged yet.</strong></p><p>Let’s check the index before and after git add.</p><pre>git-tutorial-demo on  master [?]<br>❯ git status -s<br>?? .gitignore<br>?? README.md<br>?? docs/<br>?? src/<br>?? tests/<br><br>git-tutorial-demo on  master [?]<br>❯ git ls-files --stage<br><br>it returns empty!<br><br>❯ git add .<br>warning: in the working copy of &#39;.gitignore&#39;, LF will be replaced by CRLF the next time Git touches it<br>warning: in the working copy of &#39;README.md&#39;, LF will be replaced by CRLF the next time Git touches it<br>warning: in the working copy of &#39;docs/notes.md&#39;, LF will be replaced by CRLF the next time Git touches it<br>warning: in the working copy of &#39;src/index.js&#39;, LF will be replaced by CRLF the next time Git touches it<br>warning: in the working copy of &#39;src/utils.js&#39;, LF will be replaced by CRLF the next time Git touches it<br>warning: in the working copy of &#39;tests/utils.test.js&#39;, LF will be replaced by CRLF the next time Git touches it<br><br>git-tutorial-demo on  master [+]<br>❯ git ls-files --stage<br>100644 53a89d1bf09b64af30fe2fe40310e09b0d8cfa6c 0       .gitignore<br>100644 7434fac861d8cbe0370a0fdfba6e2d43ad4c5915 0       README.md<br>100644 17e0f0dedfdc83c924c6399a21434fc8240f488c 0       docs/notes.md<br>100644 643ac3cf41824f6e02634711e6ede706f5ae0cc2 0       src/index.js<br>100644 4ed55b528897f96a26d27495885311c140a94446 0       src/utils.js<br>100644 b099333d1baac001ed76f9f3a2bce930c1dd0b29 0       tests/utils.test.js<br><br>git-tutorial-demo on  master [+]<br>❯ git reset<br><br>git-tutorial-demo on  master [?]<br>❯ git ls-files --stage<br><br>git-tutorial-demo on  master [?]<br>❯</pre><p>git-ls-files — Show information about files in the index and the working tree</p><p>Actually there are 3 commands, and 4 ways, to remove a file from the staging area (git rm has two modes). They do very different things:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O_Cl6DnF9pquwR6GVg7QXg.png" /><figcaption>Unstage, untrack or delete: three commands, and git rm has two modes. They end in very different places.</figcaption></figure><ul><li>git reset HEAD: we saw it.</li><li>git restore --staged: it really unstages the changes and the best and most modern command to restore your index area</li><li>git rm --cached: the rm command has 2 modes. This first one removes the file from the index only: the file stays on your disk and becomes untracked. If the file was already committed, its deletion is staged for the next commit.</li><li>git rm &lt;file&gt;: the second mode, careful! It does the same, and it also deletes the file from your disk.</li></ul><p>Let’s check!<br>Let’s stage one file README.md</p><pre>git-tutorial-demo on  master [?]<br>❯ git status -s<br>?? .gitignore<br>?? .serena/<br>?? README.md<br>?? docs/<br>?? src/<br>?? tests/<br><br>git-tutorial-demo on  master [?]<br>❯ git add .\README.md<br>warning: in the working copy of &#39;README.md&#39;, LF will be replaced by CRLF the next time Git touches it<br><br>git-tutorial-demo on  master [+?]<br>❯ git status -s<br>A  README.md<br>?? .gitignore<br>?? .serena/<br>?? docs/<br>?? src/<br>?? tests/<br><br>❯ git status<br>On branch master<br><br>No commits yet<br><br>Changes to be committed:<br>  (use &quot;git rm --cached &lt;file&gt;...&quot; to unstage)<br>        new file:   README.md<br><br>Untracked files:<br>  (use &quot;git add &lt;file&gt;...&quot; to include in what will be committed)<br>        .gitignore<br>        .serena/<br>        docs/<br>        src/<br>        tests/<br>❯ git ls-files --stage<br>100644 7434fac861d8cbe0370a0fdfba6e2d43ad4c5915 0       README.md</pre><p>So the file README.md is tracked and in the status “Added” in the index area.</p><p>Let’s create our first commit.</p><pre>❯ git add .\README.md<br>warning: in the working copy of &#39;README.md&#39;, LF will be replaced by CRLF the next time Git touches it<br><br>git-tutorial-demo on  master [+?]<br>❯ git commit -m &quot;My first commit: add readme.md&quot;<br>[master (root-commit) 354c1b9] My first commit: add readme.md<br> 1 file changed, 2 insertions(+)<br> create mode 100644 README.md<br><br>❯ git log --oneline<br>354c1b9 (HEAD -&gt; master) My first commit: add readme.md<br><br>❯  git ls-files --stage<br>100644 7434fac861d8cbe0370a0fdfba6e2d43ad4c5915 0       README.md<br><br>❯ git rev-parse HEAD<br>354c1b9905ed3a5d7d73cb42e32404cd85d4a49e<br><br>git-tutorial-demo on  master [?]<br>❯ git status -s<br>?? .gitignore<br>?? .serena/<br>?? docs/<br>?? src/<br>?? tests/<br><br>git-tutorial-demo on  master [?]<br>❯ git status<br>On branch master<br>Untracked files:<br>  (use &quot;git add &lt;file&gt;...&quot; to include in what will be committed)<br>        .gitignore<br>        .serena/<br>        docs/<br>        src/<br>        tests/<br><br>nothing added to commit but untracked files present (use &quot;git add&quot; to track)<br><br>❯ git show 354c1b9905ed3a5d7d73cb42e32404cd85d4a49e<br>commit 354c1b9905ed3a5d7d73cb42e32404cd85d4a49e (HEAD -&gt; master)<br>Author: xxx<br>Date:   xxx<br><br>    My first commit: add readme.md<br><br>diff --git a/README.md b/README.md<br>new file mode 100644<br>index 0000000..7434fac<br>--- /dev/null<br>+++ b/README.md<br>@@ -0,0 +1,2 @@<br>+# Git Tutorial Demo<br>+A tiny project used to demonstrate Git workflows from init to advanced commands.</pre><p>We can see that the head, index, working directory are identical for the README.md</p><pre>git-tutorial-demo on  master [?]<br>❯ git diff<br><br>git-tutorial-demo on  master [?]<br>❯ git diff --staged<br><br>git-tutorial-demo on  master [?]<br>❯</pre><p>git diff: working directory vs index</p><p>git diff --staged: index vs head</p><p>Let’s edit the file in the working directory:</p><pre># Git Tutorial Demo 2026 11 04<br>A tiny project used to demonstrate Git workflows from init to advanced commands.</pre><p>Make sure to save the file.</p><p>I just added the date, let’s run the command again</p><pre>❯ git diff<br>warning: in the working copy of &#39;README.md&#39;, LF will be replaced by CRLF the next time Git touches it<br>diff --git a/README.md b/README.md<br>index 7434fac..75ea2cc 100644<br>--- a/README.md<br>+++ b/README.md<br>@@ -1,2 +1,2 @@<br>-# Git Tutorial Demo<br>+# Git Tutorial Demo 2026 11 04<br> A tiny project used to demonstrate Git workflows from init to advanced commands.<br><br>git-tutorial-demo on  master [!?]<br>❯ git diff --staged</pre><p>For now git detected a diff of the tracked file README.md between the working directory (newly saved file) and the index (old version file of the commit). The index still have the old committed file version so git diff --staged return empty.</p><pre>❯ git status<br>On branch master<br>Changes not staged for commit:<br>  (use &quot;git add &lt;file&gt;...&quot; to update what will be committed)<br>  (use &quot;git restore &lt;file&gt;...&quot; to discard changes in working directory)<br>        modified:   README.md<br><br>Untracked files:<br>  (use &quot;git add &lt;file&gt;...&quot; to include in what will be committed)<br>        .gitignore<br>        .serena/<br>        docs/<br>        src/<br>        tests/<br><br>no changes added to commit (use &quot;git add&quot; and/or &quot;git commit -a&quot;)<br><br>git-tutorial-demo on  master [!?] took 3s<br>❯ git status -s<br> M README.md<br>?? .gitignore<br>?? .serena/<br>?? docs/<br>?? src/<br>?? tests/<br><br>git-tutorial-demo on  master [!?]<br>❯ git add .\README.md<br>warning: in the working copy of &#39;README.md&#39;, LF will be replaced by CRLF the next time Git touches it<br><br>git-tutorial-demo on  master [+?]<br>❯ git status<br>On branch master<br>Changes to be committed:<br>  (use &quot;git restore --staged &lt;file&gt;...&quot; to unstage)<br>        modified:   README.md<br><br>Untracked files:<br>  (use &quot;git add &lt;file&gt;...&quot; to include in what will be committed)<br>        .gitignore<br>        .serena/<br>        docs/<br>        src/<br>        tests/<br><br><br>git-tutorial-demo on  master [+?] took 3s<br>❯ git status -s<br>M  README.md<br>?? .gitignore<br>?? .serena/<br>?? docs/<br>?? src/<br>?? tests/<br><br>git-tutorial-demo on  master [+?]<br>❯ git diff<br><br>git-tutorial-demo on  master [+?]<br>❯ git diff --staged<br>diff --git a/README.md b/README.md<br>index 7434fac..75ea2cc 100644<br>--- a/README.md<br>+++ b/README.md<br>@@ -1,2 +1,2 @@<br>-# Git Tutorial Demo<br>+# Git Tutorial Demo 2026 11 04<br> A tiny project used to demonstrate Git workflows from init to advanced commands.</pre><p>So now we see that git tracks the file and set the status to “Modified”, we added the file to the index area, so the status went from the right to the left column in git status -s</p><pre>❯ git status -bs<br>## master<br>M  README.md<br>?? .gitignore<br>?? .serena/<br>?? docs/<br>?? src/<br>?? tests/</pre><p>Before we commit let’s try to unstage the file:</p><pre>git-tutorial-demo on  master [+?]<br>❯ git restore --staged .\README.md<br><br>git-tutorial-demo on  master [!?]<br>❯ git status -bs<br>## master<br> M README.md<br>?? .gitignore<br>?? .serena/<br>?? docs/<br>?? src/<br>?? tests/<br><br>❯ git diff<br>warning: in the working copy of &#39;README.md&#39;, LF will be replaced by CRLF the next time Git touches it<br>diff --git a/README.md b/README.md<br>index 7434fac..75ea2cc 100644<br>--- a/README.md<br>+++ b/README.md<br>@@ -1,2 +1,2 @@<br>-# Git Tutorial Demo<br>+# Git Tutorial Demo 2026 11 04<br> A tiny project used to demonstrate Git workflows from init to advanced commands.</pre><p>We can see it is easy to unstage, let’s stage and create a second commit.</p><pre>git-tutorial-demo on  master [!?]<br>❯ git add .\README.md<br>warning: in the working copy of &#39;README.md&#39;, LF will be replaced by CRLF the next time Git touches it<br><br>git-tutorial-demo on  master [+?]<br>❯ git commit -m &quot;Second Commit&quot;<br>[master 42da209] Second Commit<br> 1 file changed, 1 insertion(+), 1 deletion(-)<br><br>git-tutorial-demo on  master [?]<br>❯ git log --oneline<br>42da209 (HEAD -&gt; master) Second Commit<br>354c1b9 My first commit: add readme.md</pre><p>Now that we have two commits, let’s look at what HEAD really is.</p><p><strong>HEAD</strong></p><p><strong>HEAD</strong> is a special pointer that represents <strong>“where you currently are”</strong> in the repository.<br>In Git, the <strong>HEAD is a special pointer that references your current position in the repository’s history.</strong></p><p>It is in 2 states: Attached or not. The behavior of HEAD depends on how you navigate through your code history:</p><ul><li><strong>Attached HEAD (Normal State):</strong> HEAD points to a <strong>local branch</strong> (e.g., master or main), which in turn points to the latest commit on that branch. When you make a new commit, the branch automatically moves forward, and HEAD moves with it.</li><li><strong>Detached HEAD:</strong> HEAD points <strong>directly to a specific commit</strong> instead of a branch. This happens if you check out an older commit (e.g., git checkout &lt;commit-hash&gt;) or a remote branch. Any new commits made here do not belong to any branch and will be lost unless you actively save them.</li></ul><p>Under the Hood</p><p>Technically, HEAD is just a simple text file located inside your hidden Git folder at .git/HEAD</p><ul><li>In its normal state, it contains a reference like: refs/heads/master</li><li>In a detached state, it simply stores the raw SHA-1 hash of the specific commit.</li></ul><p>HEAD usually points to a branch, not a commit</p><pre>type .git\HEAD<br>ref: refs/heads/master</pre><p>So there are two levels of pointers:</p><p>HEAD ──► master ──► a1b2c3d (commit)</p><p>HEAD points to the branch (a “symbolic reference”).<br>The branch points to the commit (.git\refs\heads\master contains the hash)</p><p>This is why committing works the way it does. When you commit:</p><p>1. Git creates the new commit with the current commit as its parent.<br>2. Git moves the branch (master) to the new commit.<br>3. HEAD doesn’t change. It still says ref: refs/heads/master, so it moves along with the branch.</p><p>Before: HEAD ─► master ─► C2<br>After: HEAD ─► master ─► C3 &lt;─ C2</p><p>Switching branches = moving HEAD</p><pre>git switch -c feature # create the &quot;feature&quot; branch and switch to it<br>type .git\HEAD<br>ref: refs/heads/feature</pre><p>git switch (or git checkout) does two things:<br>- It rewrites .git\HEAD to point to the other branch.<br>- It updates your working files to match that branch’s commit.</p><p>Unborn HEAD (right after git init)</p><p>After git init, HEAD points to refs/heads/master, but that branch doesn’t exist yet. That’s the unborn branch we saw in git init. Your first commit creates the branch, and HEAD then works normally.</p><p>HEAD ──► master ──► ?</p><pre>git-tutorial-demo on  master [?]<br>❯</pre><p>That’s why we have [?] in the prompt of my powershell powered by starship: <a href="https://starship.rs/">https://starship.rs/</a>.</p><blockquote>To install starship on Windows for the powershell: <br>winget install --id Starship.Starship</blockquote><blockquote>Add the following to the end of your PowerShell configuration (find it by running <em>$PROFILE</em>):</blockquote><pre>Invoke-Expression (&amp;starship init powershell)</pre><p>Detached HEAD</p><p>If you check out a commit instead of a branch, HEAD points directly to that commit:</p><pre>git-tutorial-demo on  master [?]<br>❯ git log --oneline<br>42da209 (HEAD -&gt; master) Second Commit<br>354c1b9 My first commit: add readme.md<br> <br>git-tutorial-demo on  master [?]<br>❯ type .\.git\HEAD<br>ref: refs/heads/master<br> <br>git-tutorial-demo on  master [?]<br>❯ git switch --detach 42da209<br>HEAD is now at 42da209 Second Commit<br> <br>git-tutorial-demo on  HEAD (42da209) [?]<br>❯ type .\.git\HEAD<br>42da209415d8380ef64b0019634208d22e24f911<br> <br>❯ git log --oneline<br>42da209 (HEAD, master) Second Commit<br>354c1b9 My first commit: add readme.md</pre><p>HEAD ──► 42da209 (no branch involved)</p><p>The log shows (HEAD, master) instead of (HEAD -&gt; master)</p><p>- You can look around, build and test. This is useful for checking an old version.<br>- You can commit, but no branch tracks those commits. If you switch away, they become hard to find, and Git eventually deletes them.<br>- To keep them, create a branch before you leave: git switch -c keep-this.<br>- To go back without keeping anything: git switch master.</p><p><strong>git status warns you: HEAD detached at </strong>42da209<strong>.</strong></p><pre>❯ git status -sb<br>## HEAD (no branch)<br>?? .gitignore<br>?? .serena/<br>?? docs/<br>?? src/<br>?? tests/<br><br>❯ git status<br>HEAD detached at 42da209<br>Untracked files:<br>  (use &quot;git add &lt;file&gt;...&quot; to include in what will be committed)<br>        .gitignore<br>        .serena/<br>        docs/<br>        src/<br>        tests/<br><br>nothing added to commit but untracked files present (use &quot;git add&quot; to track)</pre><p>To put back the head to the branch</p><pre>git-tutorial-demo on  HEAD (42da209) [?]<br>❯ git checkout master<br>Switched to branch &#39;master&#39;<br><br>git-tutorial-demo on  master [?]<br>❯</pre><p><strong><em>Referring to commits relative to HEAD</em></strong></p><pre>Syntax            Meaning<br>----------------  ---------------------------------------------<br>HEAD              current commit<br>HEAD~1 or HEAD~   parent commit (1 step back)<br>HEAD~3            3 steps back, following first parents<br>HEAD^             first parent (same as HEAD~1)<br>HEAD^2            second parent (only for merge commits)<br>HEAD@{2}          where HEAD was 2 moves ago (from the reflog)</pre><p>Examples:</p><pre>git show HEAD # the last commit<br>git diff HEAD~1 HEAD # what the last commit changed<br>git reset --soft HEAD~1 # undo the last commit, keep its changes staged</pre><p>HEAD~2 means “go back 2 generations”. HEAD^2 means “the second parent of a merge”. They are different.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N29DFiA19tXE2v3NuGKDsw.png" /><figcaption>~ walks back through first parents, ^ picks a parent of a merge, @{n} reads the reflog.</figcaption></figure><h3>HEAD</h3><p><em>HEAD</em> is represented by the file:.git/HEADwith only one line:</p><pre>ref: refs/heads/branch-name</pre><h3>git switch branchname</h3><p>Most of the time it contains the current branch but not all the time. To change its value, we use the command</p><p>git switch yourbranch</p><p>For now we only have one branch:</p><pre>git-tutorial-demo on  master<br>❯ git branch<br>* master<br><br>git-tutorial-demo on  master [?]<br>❯</pre><p>* indicates it is the current branch</p><p>HEAD is used by the command git show: to show the current commit.</p><p>We also use HEAD in the command git log</p><pre>C:\tutorial\git-tutorial-demo&gt;git log --graph --oneline --all<br>* 42da209 (HEAD -&gt; master) Second Commit<br>* 354c1b9 My first commit: add readme.md</pre><p>We said HEAD most of the time references a branch, it is a normal use of HEAD. But sometimes we need to use HEAD in the detached mode.</p><pre>git-tutorial-demo on  master [?]<br>❯ cd .\.git\refs\<br><br><br>git-tutorial-demo\.git\refs on  master [?]<br>❯ dir<br><br><br>    Directory: C:\tutorial\git-tutorial-demo\.git\refs<br><br><br>Mode                 LastWriteTime         Length Name<br>----                 -------------         ------ ----<br>d-----        04/11/2026     10:03                heads<br>d-----        30/10/2026     09:30                tags<br><br><br><br>git-tutorial-demo\.git\refs on  master [?]<br>❯<br><br>git-tutorial-demo\.git\refs on  master [?]<br>❯ cd .\heads\<br><br>.git\refs\heads on  master [?]<br>❯ dir<br><br><br>    Directory: C:\tutorial\git-tutorial-demo\.git\refs\heads<br><br><br>Mode                 LastWriteTime         Length Name<br>----                 -------------         ------ ----<br>-a----        04/11/2026     10:03             41 master</pre><p>We see head references the master to the last commit:</p><pre><br>.git\refs\heads on  master [?]<br>❯ cat master<br>42da209415d8380ef64b0019634208d22e24f911</pre><p>which is the hash id of the last commit on the branch master:</p><pre>❯ git log --oneline<br>42da209 (HEAD -&gt; master) Second Commit<br>354c1b9 My first commit: add readme.md</pre><p>To update the branch to which it points we do:</p><pre>git update-ref refs/heads/master xxxx</pre><p>It will update the branch to point to the commit xxxx.<br>A branch in Git is: a simple pointer or reference to the head (not to be confused with HEAD I meant literally the head) of a line of work .</p><p>Git uses HEAD to find out what is the latest commit of the current branch when we do the command: git branch to create a new branch.</p><p>Usually the HEAD file is a symbolic reference to the branch you’re currently on. By symbolic reference, we mean that unlike a normal reference, it contains a pointer to another reference.</p><p><strong>The HEAD file may contain the SHA-1 value of a Git object when we use a detached HEAD.</strong></p><p>Let’s see how to trigger a detached HEAD.</p><p>For now we just have one single default branch: master. We will see later how the HEAD plays a role when we change of branch when we check out another branch.</p><p>But within our single branch we can make our HEAD move and go for example to a previous commit, it will then be in Detached Mode.<br>For this we do:</p><pre>git checkout commitid</pre><pre>.git\refs\heads on  master [?]<br>❯ git log --oneline<br>42da209 (HEAD -&gt; master) Second Commit<br>354c1b9 My first commit: add readme.md<br><br>git-tutorial-demo on  master [?]<br>❯ git checkout 42da209<br>Note: switching to &#39;42da209&#39;.<br><br>You are in &#39;detached HEAD&#39; state. You can look around, make experimental<br>changes and commit them, and you can discard any commits you make in this<br>state without impacting any branches by switching back to a branch.<br><br>If you want to create a new branch to retain commits you create, you may<br>do so (now or later) by using -c with the switch command. Example:<br><br>  git switch -c &lt;new-branch-name&gt;<br><br>Or undo this operation with:<br><br>  git switch -<br><br>Turn off this advice by setting config variable advice.detachedHead to false<br><br>HEAD is now at 42da209 Second Commit<br><br>git-tutorial-demo on  HEAD (42da209) [?]<br></pre><p>Now let’s check the log again</p><pre>❯ git log --oneline<br>42da209 (HEAD, master) Second Commit<br>354c1b9 My first commit: add readme.md</pre><pre>git-tutorial-demo on  HEAD (42da209) [?]<br>❯ git branch<br>* (HEAD detached at 42da209)<br>  master</pre><p>We can see HEAD is not pointing anymore to the master branch, but the commit! Now you can see the project as it was then. Very useful to check the file in a specific version or date.</p><p>That’s the whole story of “detached.” Normally .git\HEAD holds a symbolic reference — a pointer to a pointer (ref: refs/heads/master), which itself points to a commit. When you check out a commit directly, Git skips the indirection and writes the raw SHA-1 straight into HEAD.</p><pre>git-tutorial-demo on  HEAD (42da209) [?]<br>❯ type .\.git\HEAD<br>42da209415d8380ef64b0019634208d22e24f911</pre><p>We don’t even have a branch in the loop anymore! We point at a singled fixed commit, not at the tip of a moving line of work.</p><pre>git-tutorial-demo on  HEAD (42da209) [?]<br>❯ git status<br>HEAD detached at 42da209<br>Untracked files:<br>  (use &quot;git add &lt;file&gt;...&quot; to include in what will be committed)<br>        .gitignore<br>        .serena/<br>        docs/<br>        src/<br>        tests/<br><br>nothing added to commit but untracked files present (use &quot;git add&quot; to track)<br><br>git-tutorial-demo on  HEAD (42da209) [?] took 6s<br>❯<br><br><br>git-tutorial-demo on  HEAD (42da209) [?] took 6s<br>❯ git branch --show-current<br><br><br>git-tutorial-demo on  HEAD (42da209) [?]<br>❯</pre><p>We dont see any branch.</p><p>--show-current prints nothing — there is no branch to name.</p><p>git status explicitly flags the state so you don’t get caught out.</p><p>Why this matters: if you commit while detached, those commits are real objects in .git/objects, but no branch ref points at them. The moment you check out master again, they become unreachable from any branch — and eventually eligible for garbage collection (git gc). This is the single most common way people “lose” work in Git. It isn’t actually lost immediately — which is exactly what reflog is for — but if you never come back to look at it, it’s gone in practice.</p><p>Let’s prove that. While still detached:</p><pre>git-tutorial-demo on  HEAD (42da209) [?]<br>❯ Add-Content -Path .\README.md -Value &quot;New content&quot;<br><br>git-tutorial-demo on  HEAD (42da209) [!?]<br>❯ git status -sb<br>## HEAD (no branch)<br> M README.md<br>?? .gitignore<br>?? .serena/<br>?? docs/<br>?? src/<br>?? tests/<br><br>git-tutorial-demo on  HEAD (42da209) [!?]<br>❯ git diff<br>warning: in the working copy of &#39;README.md&#39;, LF will be replaced by CRLF the next time Git touches it<br>diff --git a/README.md b/README.md<br>index 75ea2cc..49ee32e 100644<br>--- a/README.md<br>+++ b/README.md<br>@@ -1,2 +1,3 @@<br> # Git Tutorial Demo 2026 11 04<br> A tiny project used to demonstrate Git workflows from init to advanced commands.<br>+New content<br><br>git-tutorial-demo on  HEAD (42da209) [!?]<br>❯ git commit -am &quot;experimental change while detached&quot;<br>warning: in the working copy of &#39;README.md&#39;, LF will be replaced by CRLF the next time Git touches it<br>[detached HEAD 02010aa] experimental change while detached<br> 1 file changed, 1 insertion(+)<br><br>git-tutorial-demo on  HEAD (02010aa) [?]<br>❯ git log --oneline<br>02010aa (HEAD) experimental change while detached<br>42da209 (master) Second Commit<br>354c1b9 My first commit: add readme.md<br><br>git-tutorial-demo on  HEAD (02010aa) [?]<br>❯ git log --graph<br>* commit 02010aa230bb5dd65d7ed22e2afd2e28eaed78fd (HEAD)<br>| Author: xxx<br>| Date:   Wed Nov 11 18:28:56 2026 +0100<br>|<br>|     experimental change while detached<br>|<br>* commit 42da209415d8380ef64b0019634208d22e24f911 (master)<br>| Author: xxx<br>| Date:   Wed Nov 4 10:03:43 2026 +0100<br>|<br>|     Second Commit<br>|<br>* commit 354c1b9905ed3a5d7d73cb42e32404cd85d4a49e<br>  Author: xxx<br>  Date:   Wed Nov 4 09:35:07 2026 +0100<br><br>      My first commit: add readme.md</pre><p>Notice 02010aa sits on its own line — no branch label, just HEAD. If we now switch back to master:</p><pre>❯ git switch master<br>Warning: you are leaving 1 commit behind, not connected to<br>any of your branches:<br><br>  02010aa experimental change while detached<br><br>If you want to keep it by creating a new branch, this may be a good time<br>to do so with:<br><br> git branch &lt;new-branch-name&gt; 02010aa<br><br>Switched to branch &#39;master&#39;<br><br>git-tutorial-demo on  master [?]<br>❯<br><br>git-tutorial-demo on  master [?]<br>❯ git branch mybranchcreatedfromdetachedhead 02010aa<br><br>❯ git log --oneline --graph --decorate --all<br>* 02010aa (mybranchcreatedfromdetachedhead) experimental change while detached<br>* 42da209 (HEAD -&gt; master) Second Commit<br>* 354c1b9 My first commit: add readme.md</pre><p>We can get back the hash of the commit created in detached HEAD mode</p><pre>git-tutorial-demo on  master [?]<br>❯ git reflog<br>42da209 (HEAD -&gt; master) HEAD@{0}: checkout: moving from 02010aa230bb5dd65d7ed22e2afd2e28eaed78fd to master<br>02010aa (mybranchcreatedfromdetachedhead) HEAD@{1}: commit: experimental change while detached<br>42da209 (HEAD -&gt; master) HEAD@{2}: checkout: moving from master to 42da209<br>42da209 (HEAD -&gt; master) HEAD@{3}: checkout: moving from 42da209415d8380ef64b0019634208d22e24f911 to master<br>42da209 (HEAD -&gt; master) HEAD@{4}: checkout: moving from master to 42da209<br>42da209 (HEAD -&gt; master) HEAD@{5}: checkout: moving from 42da209415d8380ef64b0019634208d22e24f911 to master<br>42da209 (HEAD -&gt; master) HEAD@{6}: checkout: moving from master to 42da209<br>42da209 (HEAD -&gt; master) HEAD@{7}: checkout: moving from 42da209415d8380ef64b0019634208d22e24f911 to master<br>42da209 (HEAD -&gt; master) HEAD@{8}: checkout: moving from master to 42da209<br>42da209 (HEAD -&gt; master) HEAD@{9}: checkout: moving from 42da209415d8380ef64b0019634208d22e24f911 to master<br>42da209 (HEAD -&gt; master) HEAD@{10}: checkout: moving from master to 42da209<br>42da209 (HEAD -&gt; master) HEAD@{11}: commit: Second Commit<br>354c1b9 HEAD@{12}: commit (initial): My first commit: add readme.md<br><br>git-tutorial-demo on  master [?]</pre><p>We find the hash, then git branch MyBranch &lt;hash&gt; — we’ll cover this properly in the reflog section, since it’s really the same mechanism.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mXPxre7e4cbKIe_Qc-Rvow.png" /><figcaption>A commit made in detached HEAD: lost when you switch away, rescued with the reflog and a new branch.</figcaption></figure><h3>Reflog</h3><p>At last let’s see how HEAD is used in reflog</p><p>Git records every move of HEAD (commit, switch, reset, rebase) in .git\logs\HEAD:</p><pre>❯ git reflog<br>fatal: your current branch &#39;master&#39; does not have any commits yet</pre><p>This is what you get right after git init: there is no commit yet, so HEAD has never moved and the reflog is empty.</p><p>- HEAD@{0} is where HEAD is now.<br>- HEAD@{1} is where it was 1 move ago, and so on.</p><pre>git reflog show master # moves of the master branch only<br>git reflog --date=iso # show timestamps<br>git log -g --oneline # reflog in log format<br>git show master@{yesterday}<br>git diff HEAD@{&quot;2 hours ago&quot;} HEAD</pre><p>The reflog (“reference log”) is a local diary of where your refs have pointed: HEAD and each branch. Each time HEAD or a branch moves, Git writes a line in it.</p><p>It records moves like:<br>- commits<br>- switch / checkout<br>- reset<br>- merge, rebase, cherry-pick, pull<br>- commit --amend</p><p>git log shows the history of commits. git reflog shows the history of your movements.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h-CxPubUwCZHN4i4qDIDog.png" /><figcaption>git log follows parent links; git reflog records every move of HEAD, lost commits included.</figcaption></figure><p>.git\logs\HEAD # moves of HEAD<br>.git\logs\refs\heads\master # moves of the master branch</p><p>They are important to get back commits</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ckpjRCjxOgpZIeDmv8EXLA.png" /><figcaption>A hard reset hides a commit; the reflog still knows its hash; a second reset brings it back.</figcaption></figure><p>Let’s prove it on our demo repo: we “lose” the second commit with a hard reset, then get it back with the reflog.</p><p>After the reset, git log only shows 354c1b9: Second Commit looks gone. But git reflog still knows where HEAD was. HEAD@{0} is the reset itself, and HEAD@{1} is where HEAD was just before: on 42da209, our “lost” commit. git reset --hard HEAD@{1} puts master back.</p><p>Notice that HEAD@{1} says checkout: moving from 02010aa… to master, not commit: Second Commit. The last move that put HEAD on 42da209 was coming back from the detached HEAD demo, so read the hash on the left, not only the message. In some PowerShell versions, wrap HEAD@{1} in single quotes.</p><pre>❯ git reset --hard HEAD~1<br>HEAD is now at 354c1b9 My first commit: add readme.md<br> <br>❯ git log --oneline<br>354c1b9 (HEAD -&gt; master) My first commit: add readme.md<br> <br>❯ git reflog -n 3<br>354c1b9 (HEAD -&gt; master) HEAD@{0}: reset: moving to HEAD~1<br>42da209 HEAD@{1}: checkout: moving from 02010aa230bb5dd65d7ed22e2afd2e28eaed78fd to master<br>02010aa (mybranchcreatedfromdetachedhead) HEAD@{2}: commit: experimental change while detached<br> <br>❯ git reset --hard HEAD@{1}<br>HEAD is now at 42da209 Second Commit<br> <br>❯ git log --oneline<br>42da209 (HEAD -&gt; master) Second Commit<br>354c1b9 My first commit: add readme.md</pre><pre>Commits are almost never deleted right away. They only become unreachable: no branch points to them any more. The reflog still knows their hashes, so you can get them back.</pre><pre>Undo a bad reset --hard<br>git reset --hard HEAD~2       # oops, two commits gone<br>git reflog                    # find the line before the reset<br>git reset --hard HEAD@{1}     # back where you were</pre><pre>Recover a deleted branch<br>git branch -D feature         # oops<br># Git prints: Deleted branch feature (was a1b2c3d).<br>git branch feature a1b2c3d    # recreate it</pre><pre>Undo a rebase that went wrong<br>git reflog                    # find &quot;rebase (start)&quot; — take the line just before it<br>git reset --hard HEAD@{5}</pre><pre>Recover commits made in detached HEAD<br>git reflog                    # find the commit made while detached<br>git switch -c rescued a1b2c3d</pre><pre>Get back the version before commit --amend<br>git reset --soft HEAD@{1}</pre><h3>git update-ref</h3><p>A branch is just a file containing a hash. Every time you commit, reset or create a branch, Git rewrites that file with a plumbing command: git update-ref. We’ll use it by hand in Part 2.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2a62b98252ed" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CKAD: Get Pod using the most cpu]]></title>
            <link>https://medium.com/@barlatiernicolas/ckad-get-pod-using-the-most-cpu-4de2f1fac2cd?source=rss-4bd015257f0a------2</link>
            <guid isPermaLink="false">https://medium.com/p/4de2f1fac2cd</guid>
            <dc:creator><![CDATA[Nicolas Barlatier]]></dc:creator>
            <pubDate>Mon, 10 Nov 2025 22:22:19 GMT</pubDate>
            <atom:updated>2025-11-10T22:22:59.327Z</atom:updated>
            <content:encoded><![CDATA[<pre>k top po --sort-by=cpu --no-headers | head -n 1 | awk &#39;{print $1,$2}&#39;<br>php-apache 1m</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4de2f1fac2cd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CKAD: how to install nginx ingress controller on KillerCoda with LoadBalancer MetalLB]]></title>
            <link>https://blog.devgenius.io/ckad-how-to-install-nginx-ingress-controller-on-killercoda-with-loadbalancer-metallb-ca9a3666cce2?source=rss-4bd015257f0a------2</link>
            <guid isPermaLink="false">https://medium.com/p/ca9a3666cce2</guid>
            <category><![CDATA[load-balancing]]></category>
            <category><![CDATA[ingress]]></category>
            <category><![CDATA[ckad-exam]]></category>
            <category><![CDATA[ingresscontroller]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Nicolas Barlatier]]></dc:creator>
            <pubDate>Sun, 09 Nov 2025 08:51:58 GMT</pubDate>
            <atom:updated>2025-11-09T08:51:58.946Z</atom:updated>
            <content:encoded><![CDATA[<p>We can install in any order, I will install first the nginx ingress controller with helm:</p><pre>helm upgrade --install ingress-nginx ingress-nginx \<br>  --repo https://kubernetes.github.io/ingress-nginx \<br>  --namespace ingress-nginx --create-namespace</pre><p>Now we need to add the loadbalancer MetalLB:</p><p>I will use the manifest</p><pre>kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.15.2/config/manifests/metallb-native.yaml</pre><p>Next you get the node IPs and you can use them so to tell the LoadBalancer which IPs are available. Finally we need to make them discoverable, the ingress controller will use one IP automatically as the external Load Balancer IP.</p><p>Finally we can map the hostname to this IP in /etc/hosts and we can reach for the ingress controller with the DNS with</p><pre>wget -O- DNS</pre><p>Below a video which can demonstrate we can do the installations and create a simple sample ingress for a basic application with a basic clusterIP service. It takes only 5 mn!</p><p>We need to look at 3 webpage links:</p><ul><li><a href="https://kubernetes.github.io/ingress-nginx/deploy/">Installation Guide - Ingress-Nginx Controller</a></li><li><a href="https://metallb.io/installation/">Installation :: MetalLB, bare metal load-balancer for Kubernetes</a></li><li><a href="https://metallb.io/configuration/">Configuration :: MetalLB, bare metal load-balancer for Kubernetes</a></li></ul><p>That is it! It is a demo and helps for learning and mastering ingress.<br>Next time I will see how to make it more like production ready !</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pYVpP24uUcmetoIYqihaWg.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ca9a3666cce2" width="1" height="1" alt=""><hr><p><a href="https://blog.devgenius.io/ckad-how-to-install-nginx-ingress-controller-on-killercoda-with-loadbalancer-metallb-ca9a3666cce2">CKAD: how to install nginx ingress controller on KillerCoda with LoadBalancer MetalLB</a> was originally published in <a href="https://blog.devgenius.io/">Dev Genius</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CKAD Service Accounts, short-lived and long-lived Tokens, Secrets]]></title>
            <link>https://blog.devgenius.io/ckad-service-accounts-short-lived-and-long-lived-tokens-secrets-0731759ba95f?source=rss-4bd015257f0a------2</link>
            <guid isPermaLink="false">https://medium.com/p/0731759ba95f</guid>
            <category><![CDATA[ckad]]></category>
            <category><![CDATA[secrets]]></category>
            <category><![CDATA[serviceaccount]]></category>
            <dc:creator><![CDATA[Nicolas Barlatier]]></dc:creator>
            <pubDate>Tue, 04 Nov 2025 12:45:26 GMT</pubDate>
            <atom:updated>2026-02-09T07:40:00.234Z</atom:updated>
            <content:encoded><![CDATA[<h3>K8s 1.24+ ServiceAccount Secret Changes</h3><p>Starting with 1.24, K8s won’t <strong>generate Secrets any longer automatically linked to ServiceAccounts.</strong></p><p><strong>Therefore we can’t find the token in the secret but we can find mounted in a pod <em>only if the pod uses this service account or by manually generating it</em></strong>.</p><pre>k create token myserviceaccountname</pre><p>It will be a short-lived token (by default 60 minutes).</p><p>We can change the duration with the option :</p><blockquote>- - duration</blockquote><p>Let’s see in action</p><pre>controlplane:~$ k create sa mysa<br>serviceaccount/mysa created<br>controlplane:~$ k create token mysa <br>eyJhbGciOiJSUzI1NiIsImtpZCI6InN0YXdpc2xNS3NVU3ZqZUlVU3ZRNG00WjdaVDlrX1d6QjVWNzJrN1RuNjQifQ.eyJhdWQiOlsiaHR0cHM6Ly9rdWJlcm5ldGVzLmRlZmF1bHQuc3ZjLmNsdXN0ZXIubG9jYWwiXSwiZXhwIjoxNzYyMTgwMjI2LCJpYXQiOjE3NjIxNzY2MjYsImlzcyI6Imh0dHBzOi8va3ViZXJuZXRlcy5kZWZhdWx0LnN2Yy5jbHVzdGVyLmxvY2FsIiwianRpIjoiNTI5NGJkZjItOGQ0My00NzE5LTg5YzUtM2M3ODgwM2M4ODY0Iiwia3ViZXJuZXRlcy5pbyI6eyJuYW1lc3BhY2UiOiJkZWZhdWx0Iiwic2VydmljZWFjY291bnQiOnsibmFtZSI6Im15c2EiLCJ1aWQiOiJkZGE0MWIwOC1lMDU3LTQ1OTItYTRmMC04Y2ViMzQ3YTQ5MTcifX0sIm5iZiI6MTc2MjE3NjYyNiwic3ViIjoic3lzdGVtOnNlcnZpY2VhY2NvdW50OmRlZmF1bHQ6bXlzYSJ9.ThxGvO5CjP-SQwbAynslDo5l49HC1RhLtBK9tJfstB9rDDzCRyozrhyZKhKS_s9k8LGlCJfytw7vktFrjPpnSer9yqMjWPqMJlZ5En0l15sBK7CrxfhILqjxZ2pVfTp7sWuyGxChmKphiydKmx1sBTBrklygka_LiGn2hOGl5cvmSa2GtXb1P0y2Fysg63mrJ7yZcc2bnvz-F749JnHQUJPh82sy98it5LPNs85dfKO-dwq5xR2EXH9J4YuY274EDPcWtmt-lY6hQr5I2_hwPQmmSRrqjgr04Yjt9neNazU-NcIAbKLaUlGZVeLYF-1chMcXon9j6bORdU00hGUW9Q</pre><p>Now let’s check the token</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GU_ONeq8ekmoGrqvVIWPUw.png" /></figure><p>Yep, it is valid 1 hour.</p><p>Ok now let’s go back into the future with the old way: when we created a service account we had also a secret.</p><p>First we created the sa mysa, now let’s look at the doc:</p><blockquote>go to Tasks =&gt; to Configure Pods and Containers =&gt; search for Service Account =&gt; go to Configure Service Accounts for Pods =&gt; search for “long-lived”</blockquote><p>We must remember this in the exam, how to look for good tasks. You find:</p><ul><li><a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/">Configure Service Accounts for Pods</a></li><li><a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/#manually-create-a-long-lived-api-token-for-a-serviceaccount">Configure Service Accounts for Pods</a></li></ul><h3>Manually create a long-lived API token for a ServiceAccount</h3><pre>kubectl apply -f - &lt;&lt;EOF<br>apiVersion: v1<br>kind: Secret<br>metadata:<br>  name: mysa-secret<br>  annotations:<br>    kubernetes.io/service-account.name: mysa<br>type: kubernetes.io/service-account-token<br>EOF</pre><p>Let’s see in video</p><p>Now we see a secret with the annotation :</p><blockquote>Annotations: kubernetes.io/service-account.name: mysa<br>and the token in the data.</blockquote><p>Now we can find all the secrets of Type: kubernetes.io/service-account-token</p><pre>kubectl get secrets -A <br>-o jsonpath=&#39;{range .items[?(@.type==&quot;kubernetes.io/service-account-token&quot;)]}{.metadata.namespace}/{.metadata.name}{&quot;\n&quot;}{end}&#39;</pre><p><strong>Cheers</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0731759ba95f" width="1" height="1" alt=""><hr><p><a href="https://blog.devgenius.io/ckad-service-accounts-short-lived-and-long-lived-tokens-secrets-0731759ba95f">CKAD Service Accounts, short-lived and long-lived Tokens, Secrets</a> was originally published in <a href="https://blog.devgenius.io/">Dev Genius</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CKAD Best exercises with videos Part 5]]></title>
            <link>https://blog.devgenius.io/ckad-best-exercises-with-videos-part-5-ccabecd71666?source=rss-4bd015257f0a------2</link>
            <guid isPermaLink="false">https://medium.com/p/ccabecd71666</guid>
            <category><![CDATA[exam]]></category>
            <category><![CDATA[ckad]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[exams-preparation]]></category>
            <dc:creator><![CDATA[Nicolas Barlatier]]></dc:creator>
            <pubDate>Sat, 25 Oct 2025 22:38:24 GMT</pubDate>
            <atom:updated>2025-10-27T12:12:10.486Z</atom:updated>
            <content:encoded><![CDATA[<p>TOC</p><p>· <a href="#1eef">28- SecurityContext</a><br>· <a href="#d363">29- Service</a><br>· <a href="#a21e">30- Troubleshooting-service</a><br>· <a href="#a1b2">31- Ingress</a><br>· <a href="#aa23">32- Networkpolicies</a></p><p>We keep going doing the CKAD exercises: go to <a href="https://medium.com/dev-genius/ckad-best-exercises-with-videos-part-1-b9e7ad01e3d8">https://medium.com/dev-genius/ckad-best-exercises-with-videos-part-1-b9e7ad01e3d8</a> to see the Part 1. It is the ultimate part, thank god :)</p><h3>28- SecurityContext</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eK8VKl6CtHY9zJci7r7HVA.gif" /></figure><p>It is a simple question, a bit long, we need to create the pod, the volume, and set SecurityContext in two different places: Pod and Container we need to be aware of this! Not all settings are available in the two level of SecurityContext. It takes 6 mn to resolve the question. We need to be aware how to format our yaml and our command (It messed up the format).<br>So to win time, be aware of these subtleties.</p><h3>29- Service</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D7WIVdhRmnwMentb2t6aBA.gif" /></figure><p>It is a very basic question about 2 types of services. It takes 3 mn to resolve it. It is the kind of questions we should resolve first before tackling the very hard questions.</p><h3>30- T<a href="https://github.com/bmuschko/ckad-crash-course/tree/master/exercises/30-troubleshooting-service">roubleshooting-service</a></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dBfLZOFtNXBD_30gtpGPmw.gif" /></figure><p>This is an excellent CKAD exam question and one of the more interesting ones. It can be somewhat challenging if you are unsure where to begin troubleshooting.</p><p>When encountering an issue with Kubernetes Services, start by verifying the <strong>labels</strong> and then check the <strong>ports</strong>. Additionally, ensure that there are no <strong>NetworkPolicies</strong> restricting network traffic. Although such a scenario would be a tricky inclusion in the exam, it remains a possibility.</p><p>It takes about 6 mn to resolve it if you know where to look, otherwise it could take 10 mn or worse if you are lost.</p><p>Look at the page:</p><p><a href="https://kubernetes.io/docs/tasks/debug/debug-application/debug-service/">Debug Services</a></p><h3>31- <a href="https://github.com/bmuschko/ckad-crash-course/tree/master/exercises/30-troubleshooting-service">Ingress</a></h3><p>In killercoda we need to install the ingress controller, we use the community nginx ingress controller, the free one :</p><p><a href="https://kubernetes.github.io/ingress-nginx/">Welcome - Ingress-Nginx Controller</a></p><p>We will use Helm, the k8s package manager :=)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UBbF_Mfq2zsezlItArx4Fw.gif" /></figure><p>It is a good example of a question for CKAD, how to add the helm repo, update it, and install the chart :=)</p><p>We can check it works properly.</p><p>We need to check the pod in the running state.</p><p>We have a nodeport service that we will use for reaching our service outside the cluster.</p><pre>controlplane:~$ k get all -n ingress-nginx <br>NAME                                            READY   STATUS    RESTARTS   AGE<br>pod/ingress-nginx-controller-6f6c964579-4bmrz   1/1     Running   0          6m56s<br><br>NAME                                         TYPE           CLUSTER-IP      EXTERNAL-IP   PORT(S)                      AGE<br>service/ingress-nginx-controller             LoadBalancer   10.107.204.50   &lt;pending&gt;     80:30128/TCP,443:31929/TCP   6m56s<br>service/ingress-nginx-controller-admission   ClusterIP      10.99.215.216   &lt;none&gt;        443/TCP                      6m56s<br><br>NAME                                       READY   UP-TO-DATE   AVAILABLE   AGE<br>deployment.apps/ingress-nginx-controller   1/1     1            1           6m56s<br><br>NAME                                                  DESIRED   CURRENT   READY   AGE<br>replicaset.apps/ingress-nginx-controller-6f6c964579   1         1         1       6m56s<br>controlplane:~$ </pre><p>Now let’s create and expose the app with a single replica (we don’t need to set the number of replicas) and let’s make sure the app is reachable with the service, so we make sure the problem we could meet is not there.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iqrL4SDFqgvnFDsd3CK9tw.gif" /></figure><p>Now we are ready to create our ingress.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VX9Y6eC9ReTnnbJOan0QTA.gif" /></figure><p>We tested from a temp pod if we could reach for the app with the ip of the ingress controller and with the header host.</p><p>We can do the same thing from outside the cluster, we can reach for the node ip with the nodeport of the ingress controller:</p><p>First we will use the wget method, we will use the node ip and nodeport to reach for the ingress controller, and we send the host header to match the ingress rule. We need to do this because we do not have an ingress controller loadbalancer with an external IP</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d5N8v7o8BOQ59aPHgSxjmA.gif" /></figure><p>Unfortunately we don’t have the IP of the ingress</p><pre>controlplane:~$ k get ingress<br>NAME       CLASS   HOSTS                 ADDRESS   PORTS   AGE<br>ingress1   nginx   hello-world.exposed             80      18m</pre><p>We could then use this ip address and map it to hello-world.exposed and use the port: 80</p><pre>wget -O- hello-world.exposed</pre><p>No need of host header!</p><p>Below we can use curl instead of wget:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pRzOT_YBaBoDKMI996n8mA.gif" /></figure><p>And in the ingress controller pod we can see in the logs the accesses.</p><p>This question is pretty easy when we master the k create ingress command. It takes about 6 mn.</p><p>Now the very last question, the networkpolicies! Probably the most delicate subject but it’s pretty easy for the CKAD exam.</p><h3>32- <a href="https://github.com/bmuschko/ckad-crash-course/tree/master/exercises/30-troubleshooting-service">Networkpolicies</a></h3><p>First we need to see if we have a CNI plugin in killercode which supports networkpolicies:</p><pre>controlplane:~$ k get all -A | grep -i calico<br>kube-system          pod/calico-kube-controllers-7bb4b4d4d-8q2r8     1/1     Running   3 (3h22m ago)   5d21h<br>kube-system          deployment.apps/calico-kube-controllers    1/1     1            1           5d21h<br>kube-system          replicaset.apps/calico-kube-controllers-7bb4b4d4d     1         1         1       5d21h<br>controlplane:~$ </pre><p>Calico supports networkpolicies!</p><p>Now we can answer the question:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tgDxG6GXzCsfIL0pMA5EGA.gif" /></figure><pre>apiVersion: networking.k8s.io/v1<br>kind: NetworkPolicy<br>metadata:<br>  name: default-deny-ingress<br>  namespace: k2<br>spec:<br>  podSelector: {}<br>  policyTypes:<br>  - Ingress</pre><p>We just created 2 namespaces k1 and k2, pods in them, and a networkpolicy which denies any traffic to any pod inside the namespace k2 and from any pod from any other namespace (k1 or even k2 itself!). We made sure that a pod in the namespace n1 can not reach for the pod in the namespace k2!</p><p>Let’s check if we can reach for this pod within the same namespace k2!</p><p>Nope it is still blocked, so even the pods of the same namespace k2 can’t reach for any pod of the same namespace k2…</p><p>So we have:</p><p>| Direction | Allowed? | Why |<br>| Pod in `k2` → Pod in `k2` | ❌ | Ingress to the destination pod is denied |<br>| Pod in `k2` → Pod in another namespace | ✅ (if no egress policy) | Egress unrestricted |<br>| Pod outside `k2` → Pod in `k2` | ❌ | Ingress denied |</p><p>Ok now, we need to understand, we will tell that the backend pod in the namespace k2 will allow ingress traffic from ANY pod of the namespace k1.</p><p>Let’s do it in video, remember we need to do it with YAML only.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AO-mMb7l_WpixIn72r1VBw.gif" /></figure><p>We have to remember: we need to make sure the namespaces are with labels when we need to select by namespace in the netpol, and we need to make sure we select the expected pods to which the netpol is applied to with the labels again. So Labels are important to master:</p><p><a href="https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/">Labels and Selectors</a></p><p>That question is delicate and need a bit of time to make sure we don’t mess it up, it would probably take 10 mn but could take 6 mn if you are used to create netpol. I showed in the video you could add the port to filter better, but if you omitted it, it would open to any port.</p><p>Ok for all these questions it would take 35 mn at the worse case scenario.</p><p><strong>Conclusion</strong></p><p>Phew, we’re done with these CKAD exercises!<br> I hope you found them useful. I solved each question in my own way — you can check the official solutions in the Git repository, but they often provide all the YAML at once. Personally, I think it’s better to use kubectl commands whenever possible (except for NetworkPolicies, where YAML files are necessary).</p><p>Please let me know if I made any mistakes in the videos, or if you have a better solution — I’d love to hear your feedback.<br> Feel free to reach out anytime with questions or comments.</p><p>I’ll be taking the CKAD exam in the next few days, and I don’t think it will be too difficult :) I’ve trained well with these 32 exercises! I took me about 9 days :)</p><p>I’ll also be posting new blogs about the CKAD, then moving on to the CKA, and finally the hardest one — the CKS!</p><p>After that, I plan to study AI, since it will likely automate much of Kubernetes and other cluster technologies in the future.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ccabecd71666" width="1" height="1" alt=""><hr><p><a href="https://blog.devgenius.io/ckad-best-exercises-with-videos-part-5-ccabecd71666">CKAD Best exercises with videos Part 5</a> was originally published in <a href="https://blog.devgenius.io/">Dev Genius</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CKAD Best exercises with videos Part 4]]></title>
            <link>https://medium.com/@barlatiernicolas/ckad-best-exercises-with-videos-part-4-4b3d665345f9?source=rss-4bd015257f0a------2</link>
            <guid isPermaLink="false">https://medium.com/p/4b3d665345f9</guid>
            <category><![CDATA[ckad]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[exam]]></category>
            <dc:creator><![CDATA[Nicolas Barlatier]]></dc:creator>
            <pubDate>Wed, 22 Oct 2025 15:40:53 GMT</pubDate>
            <atom:updated>2025-10-22T15:40:53.794Z</atom:updated>
            <content:encoded><![CDATA[<p>We keep going doing the CKAD exercises: go to <a href="https://medium.com/dev-genius/ckad-best-exercises-with-videos-part-1-b9e7ad01e3d8">https://medium.com/dev-genius/ckad-best-exercises-with-videos-part-1-b9e7ad01e3d8</a> to see the Part 1</p><p>TOC</p><p>· <a href="#3b7e">22- rbac-serviceaccount</a><br>· <a href="#855c">23- resource-requests-limits</a><br>· <a href="#7e76">24- resourcequota</a><br>· <a href="#b6f6">25- limitrange</a><br>· <a href="#e63f">26- Configmap</a><br>· <a href="#d7ce">27- Secret</a></p><h3>22- rbac-serviceaccount</h3><p>This is the hardest question and it took me a whole 8 minutes to resolve. It may be the question you should do last. It’s challenging because you need to have a good understanding of how to use curl with JWT tokens, as well as the structure of ClusterRole, ClusterRoleBinding, and Kubernetes API resources…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pPiKCNFw9JR9HgIPRW6aaA.gif" /><figcaption>r</figcaption></figure><h3>23- resource-requests-limits</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OntZV2s0bbSs1d35SBB8rA.gif" /></figure><p>A very simple question it takes about 4 mn.</p><h3>24- resourcequota</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vFZiKkdpegMISixXKP3LSw.gif" /></figure><p>It is a very basic question, it takes 3 mn.<br>To remember resourcequota limit resource use of a given namespace of all the objects including the number of objects, it uses the aggregate of all objects of a namepsace</p><h3>25- limitrange</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KBMIK30dtVQ9BmgeKXL0bw.gif" /></figure><p>It is a very basic question with 3 tasks, it takes about 4 mn.<br>We need to remember resourcequota deals with resource usage within a given namespace, limitrange deals with resource usage for a given object type or several object types.</p><p>To master well the difference between resourcequota and limitranges these blogs help (but go beyond the scope of the CKAD)</p><ul><li><a href="https://www.perfectscale.io/blog/kubernetes-resource-quotas-limit-ranges">Hands-on Guide on Kubernetes Resource Quotas &amp; Limit Ranges</a></li><li><a href="https://www.perfectscale.io/blog/kubernetes-resource-limits-and-requests">Kubernetes Resource Limits vs Requests: Ultimate Guide</a></li></ul><h3>26- Configmap</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GPHPOG9OFUbCjl7EJ1c5Jw.gif" /></figure><p>It is a basic question it takes about 4 mn. You can find all info on the link:</p><p><a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/">Configure a Pod to Use a ConfigMap</a></p><p>We need to find the page called “Configure a Pod to Use a ConfigMap” and find the title Add ConfigMap data to a Volume</p><p><a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#add-configmap-data-to-a-volume">Configure a Pod to Use a ConfigMap</a></p><h3>27- Secret</h3><p><a href="https://kubernetes.io/fr/docs/concepts/configuration/secret/">Secrets</a></p><p>It is a basic question it takes about 4 mn.</p><p><strong>Conclusion: it is the end of the part 4, we did 6 questions and it took about 23 min, the questions were simpler. I hope it was useful, see you on the next and very last part 5 !</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4b3d665345f9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CKAD Best exercises with videos Part 3]]></title>
            <link>https://blog.devgenius.io/ckad-best-exercises-with-videos-part-3-1ee6b1cb5e23?source=rss-4bd015257f0a------2</link>
            <guid isPermaLink="false">https://medium.com/p/1ee6b1cb5e23</guid>
            <category><![CDATA[k8s]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[exam]]></category>
            <category><![CDATA[ckad]]></category>
            <dc:creator><![CDATA[Nicolas Barlatier]]></dc:creator>
            <pubDate>Fri, 17 Oct 2025 12:33:51 GMT</pubDate>
            <atom:updated>2025-10-21T11:15:28.462Z</atom:updated>
            <content:encoded><![CDATA[<p>TOC</p><p>· <a href="#adb1">16- kustomize-secret-patch</a><br>· <a href="#1cfb">17- Api-deprecation</a><br>· <a href="#f4da">18- Pod Probes</a><br>· <a href="#d557">19- Pod Metrics</a><br>· <a href="#7fdf">20- Troubleshooting Pod</a><br>· <a href="#00f1">21- CRDs</a></p><p>We keep going doing the CKAD exercises: go to <a href="https://medium.com/dev-genius/ckad-best-exercises-with-videos-part-1-b9e7ad01e3d8">https://medium.com/dev-genius/ckad-best-exercises-with-videos-part-1-b9e7ad01e3d8</a> to see the Part 1</p><h3>16- kustomize-secret-patch</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D7Sr-aPPmfCaSlVbibxpOQ.gif" /></figure><p>It is an interesting question because it shows that Kustomize can be used without base and overlays structure explicitely created with directories. The base was a deployment.yaml file and we overlayed the secret created with a secret generator through a <strong>strategicMerge yaml patch</strong>. Go to <a href="https://kubernetes.io/docs/tasks/manage-kubernetes-objects/kustomization/">https://kubernetes.io/docs/tasks/manage-kubernetes-objects/kustomization/</a> to master this part. It takes about 5 min to answer this question.</p><p>Be careful to add the namespace in the secretgenerator otherwise the secret will be in the default namespace!</p><h3>17- <a href="https://github.com/bmuschko/ckad-crash-course/tree/master/exercises/17-api-deprecation">Api-deprecation</a></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ergSCgQgm9m5LvGMV-gAdA.gif" /></figure><p>A very basic question but interesting because it shows us how to check for the resource information. It takes about 2 min to resolve it. I created a deployment in yaml output so I don’t have to remember how to create all the deployment structure.</p><h3>18- <a href="https://github.com/bmuschko/ckad-crash-course/tree/master/exercises/17-api-deprecation">Pod Probes</a></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q1BRrbJDaC3_T5nex4XF7A.gif" /></figure><p>It is a very simple question we just need to know a bit about probes and httpget, it takes 3 minutes.</p><h3>19- <a href="https://github.com/bmuschko/ckad-crash-course/tree/master/exercises/17-api-deprecation">Pod Metrics</a></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QoSt3zFggUQ7ggBfvC_pSQ.gif" /></figure><p>For Killercoda we need to install the metrics server and make it work because killercoda is without proper TLS certificates on the kubelet API !</p><p>The metrics-server contacts the <strong>kubelet</strong> on each node at port 10250 over HTTPS.</p><p>In production-grade clusters:</p><ul><li>Nodes use proper TLS certificates issued by a trusted CA.</li><li>DNS is fully working.</li><li>kubelet uses verified certificates.</li></ul><p>✅ metrics-server connects securely, verifies certs, and collects metrics.</p><p>❗ The Problem in Self-Hosted Clusters</p><p>In local or self-hosted clusters (e.g. minikube, kubeadm, kind, etc.):The kubelet often uses a self-signed TLS certificate.<br>The certificate may not match the node hostname (DNS mismatch).<br>metrics-server tries to verify the cert, fails, and throws an error!</p><p>It is a simple question, it takes about 3 min (without the installation of metrics)</p><p>You solve this by <strong>telling metrics-server to ignore TLS verification</strong> and <strong>use a better method to reach kubelets</strong>.</p><p>— kubelet-insecure-tls <br>Tells metrics-server to <strong>skip TLS verification</strong> when connecting to kubelets. Needed when kubelet certs are self-signed or not properly trusted.</p><p>— kubelet-preferred-address-types=InternalIP<br>Tells metrics-server to connect using <strong>internal IPs</strong> instead of node names or hostnames, which may not resolve in self-hosted environments.</p><p>In production, you should:</p><ul><li>Set up valid TLS certificates for kubelets.</li><li>Ensure nodes are resolvable and reachable</li></ul><pre>kubectl debug -it date-recorder --image=busybox --target=date-recorder</pre><pre>kubectl debug -it date-recorder --image=busybox --share-processes --copy-to=date-recorder-debug</pre><h3>20- <a href="https://github.com/bmuschko/ckad-crash-course/tree/master/exercises/17-api-deprecation">Troubleshooting Pod</a></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H_3UAQIBuGzRrit2maesHQ.gif" /></figure><p>We need to master the ephemeral container here, it is pretty easy, it takes about 4 mn to answer this question.</p><ul><li><a href="https://kubernetes.io/docs/tasks/debug/debug-application/debug-running-pod/#ephemeral-container-example">Debug Running Pods</a></li><li><a href="https://kubernetes.io/docs/tasks/debug/debug-application/debug-running-pod/#ephemeral-container-example">Debug Running Pods</a></li></ul><p>So sometimes we can add a container to a pod with a distroless container. Other time it is not possible so we need to copy the pod with the newly added container or we need to keep the original pod (like on pod) and we try to reproduce the problem in the newly created pod with 2 containers: the original app one and the debugging ephemeral container.</p><h3>21- CRDs</h3><p>We need to read three resources:</p><ul><li><a href="https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/">Custom Resources</a></li><li><a href="https://kubernetes.io/docs/concepts/architecture/controller/">Controllers</a></li><li><a href="https://kubernetes.io/docs/concepts/extend-kubernetes/operator/">Operator pattern</a></li></ul><p>The first one explains how to add new <strong>resources </strong>to K8s with CRD, the second one explains how to use the CRD with a controller (not in the CKAD exam, but it is important to know), the last one is a design pattern of the CRD and controller which is important to master. (not in the CKAD exam)</p><blockquote><strong>A <em>resource</em> is an endpoint in the </strong><a href="https://kubernetes.io/docs/concepts/overview/kubernetes-api/"><strong>Kubernetes API</strong></a><strong> that stores a collection of </strong><a href="https://kubernetes.io/docs/concepts/overview/working-with-objects/#kubernetes-objects"><strong>API objects</strong></a><strong> of a certain kind;</strong></blockquote><blockquote>Not to confuse with Resources in the YAML resources &lt;ResourceRequirements&gt;<br> <a href="https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/">https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/</a></blockquote><p>To master CRD for the exam</p><p><a href="https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/">Extend the Kubernetes API with CustomResourceDefinitions</a></p><pre>apiVersion: apiextensions.k8s.io/v1<br>kind: CustomResourceDefinition<br>metadata:<br>  # name must match the spec fields below, and be in the form: &lt;plural&gt;.&lt;group&gt;<br>  name: crontabs.stable.example.com<br>spec:<br>  # group name to use for REST API: /apis/&lt;group&gt;/&lt;version&gt;<br>  group: stable.example.com<br>  # list of versions supported by this CustomResourceDefinition<br>  versions:<br>    - name: v1<br>      # Each version can be enabled/disabled by Served flag.<br>      served: true<br>      # One and only one version must be marked as the storage version.<br>      storage: true<br>      schema:<br>        openAPIV3Schema:<br>          type: object<br>          properties:<br>            spec:<br>              type: object<br>              properties:<br>                cronSpec:<br>                  type: string<br>                image:<br>                  type: string<br>                replicas:<br>                  type: integer<br>  # either Namespaced or Cluster<br>  scope: Namespaced<br>  names:<br>    # plural name to be used in the URL: /apis/&lt;group&gt;/&lt;version&gt;/&lt;plural&gt;<br>    plural: crontabs<br>    # singular name to be used as an alias on the CLI and for display<br>    singular: crontab<br>    # kind is normally the CamelCased singular type. Your resource manifests use this.<br>    kind: CronTab<br>    # shortNames allow shorter string to match your resource on the CLI<br>    shortNames:<br>    - ct</pre><p>We just need to copy this and adapt like in the video:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MYvStS7-B_6fFTA0Hzwi_w.gif" /></figure><p>We need to create the crd then its instance, it takes about 6 mn.<br>Nothing complex but we need to know well the doc.</p><p><strong>Conclusion: it is the end of the part 6, we did 6 questions and it took about 23 min, the questions were simpler. I hope it was useful, see you on the next part 3.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1ee6b1cb5e23" width="1" height="1" alt=""><hr><p><a href="https://blog.devgenius.io/ckad-best-exercises-with-videos-part-3-1ee6b1cb5e23">CKAD Best exercises with videos Part 3</a> was originally published in <a href="https://blog.devgenius.io/">Dev Genius</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CKAD Best exercises with videos Part 2]]></title>
            <link>https://blog.devgenius.io/ckad-best-exercises-with-videos-part-2-bf571ca6fa48?source=rss-4bd015257f0a------2</link>
            <guid isPermaLink="false">https://medium.com/p/bf571ca6fa48</guid>
            <category><![CDATA[videos]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[ckad]]></category>
            <category><![CDATA[exam]]></category>
            <dc:creator><![CDATA[Nicolas Barlatier]]></dc:creator>
            <pubDate>Wed, 15 Oct 2025 16:17:12 GMT</pubDate>
            <atom:updated>2025-10-17T09:47:47.945Z</atom:updated>
            <content:encoded><![CDATA[<p>We keep going doing the CKAD exercises: go to <a href="https://medium.com/dev-genius/ckad-best-exercises-with-videos-part-1-b9e7ad01e3d8">https://medium.com/dev-genius/ckad-best-exercises-with-videos-part-1-b9e7ad01e3d8</a> to see the Part 1</p><p>· <a href="#fc7c">10- Labels Annotations</a><br>· <a href="#3576">11- Deployment-rolling-update</a><br>· <a href="#7737">12- Deployment-horizontal-pod-autoscaler</a><br>· <a href="#6a30">13- Deployment-blue-green</a><br>· <a href="#c280">14- Helm-consume-chart</a><br>· <a href="#9b11">15- Helm-build-chart</a></p><h3>10- Labels Annotations</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cJWhz_4F4M0T8ZIfU8Ykzg.gif" /></figure><p>It is a simple question, it takes a little while to add three labels/annotations per pod, it takes about 5 min to do all the tasks.</p><h3>11- D<a href="https://github.com/bmuschko/ckad-crash-course/tree/master/exercises/11-deployment-rolling-update">eployment-rolling-update</a></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M2RLVj6jvibvl_cDfw6l6g.gif" /></figure><p>It is long question with many tasks but they are simple, we need to master the rollout and the well known annotations. It takes about 4 min to complete.</p><h3>12- D<a href="https://github.com/bmuschko/ckad-crash-course/tree/master/exercises/12-deployment-horizontal-pod-autoscaler">eployment-horizontal-pod-autoscaler</a></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*79TiaoWtYsZmGO8654-WLQ.gif" /></figure><p>This question is very easy, it takes a bit a time to build the hpa, we took 5 min.</p><h3>13- <a href="https://github.com/bmuschko/ckad-crash-course/tree/master/exercises/13-deployment-blue-green">Deployment-blue-green</a></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tZcdAb4GnW3ovlh5vmeQag.gif" /></figure><p>Very simple question it takes 4 minutes.</p><h3>14- <a href="https://github.com/bmuschko/ckad-crash-course/tree/master/exercises/14-helm-consume-chart">Helm-consume-chart</a></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tEONRnYSbd-dtGIn29KenQ.gif" /></figure><p>Well it was pretty easy, we need to master a minimum of helm commands. It takes about 4 min.</p><h3>15- <a href="https://github.com/bmuschko/ckad-crash-course/tree/master/exercises/14-helm-consume-chart">Helm-build-chart</a></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QK8DMPVNeqpqDzCwC8II2w.gif" /></figure><p>To save the helm in a package</p><pre>controlplane:~/myhelm$ helm package .<br>Successfully packaged chart and saved it to: /root/myhelm/myhelm-2.5.4.tgz</pre><p>it is a question which is pretty harder but if we master well the helm chart structure we can do it in 6 minutes.</p><p><strong>Conclusion: it is the end of the part 2, we did 6 questions and it took about 28 min, so a bit like the part 1 but we did less questions as they were longer. I hope it was useful, see you on the next part 3.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bf571ca6fa48" width="1" height="1" alt=""><hr><p><a href="https://blog.devgenius.io/ckad-best-exercises-with-videos-part-2-bf571ca6fa48">CKAD Best exercises with videos Part 2</a> was originally published in <a href="https://blog.devgenius.io/">Dev Genius</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CKAD Best exercises with videos Part 1]]></title>
            <link>https://blog.devgenius.io/ckad-best-exercises-with-videos-part-1-b9e7ad01e3d8?source=rss-4bd015257f0a------2</link>
            <guid isPermaLink="false">https://medium.com/p/b9e7ad01e3d8</guid>
            <category><![CDATA[training]]></category>
            <category><![CDATA[exam]]></category>
            <category><![CDATA[videos]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[ckad]]></category>
            <dc:creator><![CDATA[Nicolas Barlatier]]></dc:creator>
            <pubDate>Mon, 13 Oct 2025 22:02:16 GMT</pubDate>
            <atom:updated>2025-10-17T09:44:31.190Z</atom:updated>
            <content:encoded><![CDATA[<p>First: all the exercises are available in the book of Benjamin Muschko, he did an amazing book, I will not give it the name because he must allow me. But you can find it easily on internet.</p><p>He gave for free all exercises in git:</p><p><a href="https://github.com/bmuschko/ckad-crash-course">GitHub - bmuschko/ckad-crash-course: In-depth and hands-on practice for acing the exam.</a></p><p>All exercises are there</p><p><a href="https://github.com/bmuschko/ckad-crash-course/tree/master/exercises">ckad-crash-course/exercises at master · bmuschko/ckad-crash-course</a></p><p>We will start with the 9 first exercices so the page will not be too long :)</p><p>· <a href="#5c3c">1- Containers</a><br>· <a href="#65c9">2- Pods</a><br>· <a href="#c788">3- Job</a><br>· <a href="#280b">4- CronJob</a><br>· <a href="#335c">5- Ephemeral-volume</a><br>· <a href="#0676">06-persistentvolume-static-provisioning</a><br>· <a href="#3864">07-Init Container</a><br>· <a href="#3533">08-Adapter Pattern</a><br>· <a href="#8f5e">09-Ambassador Pattern</a></p><h3><strong>1- Containers</strong></h3><p><a href="https://github.com/bmuschko/ckad-crash-course/tree/master/exercises/01-container">ckad-crash-course/exercises/01-container at master · bmuschko/ckad-crash-course</a></p><p>I will do the first section Containers on video</p><p><a href="https://github.com/bmuschko/ckad-crash-course/blob/master/exercises/01-container/instructions.md">ckad-crash-course/exercises/01-container/instructions.md at master · bmuschko/ckad-crash-course</a></p><p>First we need to git clone the whole repo <a href="https://github.com/bmuschko/ckad-crash-course/tree/master">https://github.com/bmuschko/ckad-crash-course/tree/master</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5TcsT7nJwPbTEYuuactw8A.gif" /></figure><p>Ok now we are ready to do the first exercise Containers</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ukMGHHQx-HnfP0iiQSl0Lg.gif" /></figure><p>It takes about 2 minutes to resolve it and about 1minute to read the question so about 3 minutes. It is a very simple question but we need to know pretty well the docker commands and not only kubectl.</p><h3>2- Pods</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jT9fbzl9YyxKbHf1ZDVDtQ.gif" /></figure><p>It is a very simple question but with many tasks, it takes about 4 minutes.</p><h3>3- Job</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bu_yA8PAEiK5a0gKImXpcA.gif" /></figure><p>This exercise was very simple, just know how to create a job with a basic command and some options, it takes about 2 minutes.</p><h3>4- CronJob</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l-cOJLBbDh843zC9vu_Ovg.gif" /></figure><p>Very simple it takes 3 min, we just need to master two notions: the schedule format and the limit.</p><h3>5- <a href="https://github.com/bmuschko/ckad-crash-course/tree/master/exercises/05-ephemeral-volume">Ephemeral-volume</a></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HzcTdQuH1A6ZWqRugZlz3Q.gif" /></figure><p>The question was simple but a bit long with repetive tasks and it has a question about security, it takes about 4 minutes.</p><h3>06-persistentvolume-static-provisioning</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6XoeT8oYs7LXht2MKRAieQ.gif" /></figure><p>It is a very simple question with the kubernets documentation, search for “pv task” and copy/paste. It takes about 5 min because we need to create 3 yml.</p><h3>07-Init Container</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z-zjyCNxeiIFXIJuFnzPjA.gif" /></figure><p>it took about 4 minutes we just need to master wget command.</p><h3>08-Adapter Pattern</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GutioLz835sk4ux5Akm1-A.gif" /></figure><p>It is pretty long but simple, two containers sharing a volume, one writing the same info, the second one transforming it. It took about 5 min to solve it. I was a bit confused because in the transformer, the shared volume and file <strong>var/logs/diskspace.txt </strong>was the entry of the transformation and the <strong>output (result) files were in the “/” folder with the mention transformed.</strong></p><h3>09-Ambassador Pattern</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lO5lsoMD1do1fz6EShAesg.gif" /></figure><p>It is a very simple question, we need to read the text and get the essential information to build our yaml. it takes more time like 6 min.</p><p><strong>Conclusion: it is the first part, we can see it is pretty easy to pass the CKAD but we need to be ultra fast, it is better to know well kubectl, the doc and go to the point! It took about 30 min to answer 9 questions. Obviously we need to read carefully the questions, so actually we need 40 minutes. So if have 20 question it could take 100 minutes : 1h 40 minutes, so we can have 20 minutes to read all again, it is a time pressure exam for sure.</strong></p><p>Please make me know if you found the videos useful, you can see I start from scratch except for PV and PVC.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b9e7ad01e3d8" width="1" height="1" alt=""><hr><p><a href="https://blog.devgenius.io/ckad-best-exercises-with-videos-part-1-b9e7ad01e3d8">CKAD Best exercises with videos Part 1</a> was originally published in <a href="https://blog.devgenius.io/">Dev Genius</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CKAD: How to Create a network policy in 3 Minutes (Video Guide)]]></title>
            <link>https://blog.devgenius.io/ckad-how-to-create-a-network-policy-in-3-minutes-video-guide-314fb5a08111?source=rss-4bd015257f0a------2</link>
            <guid isPermaLink="false">https://medium.com/p/314fb5a08111</guid>
            <category><![CDATA[videos]]></category>
            <category><![CDATA[ckad]]></category>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[network-policies]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Nicolas Barlatier]]></dc:creator>
            <pubDate>Tue, 07 Oct 2025 20:09:14 GMT</pubDate>
            <atom:updated>2025-10-10T12:40:11.183Z</atom:updated>
            <content:encoded><![CDATA[<p>In this video, we’ll walk through how to create a network policy linking pods in two different namespaces, using a KillerCoda scenario. You’ll see how to resolve common issues and test the setup — all in one short session.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IivIUQapHr0ptCfKqgjkFg.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=314fb5a08111" width="1" height="1" alt=""><hr><p><a href="https://blog.devgenius.io/ckad-how-to-create-a-network-policy-in-3-minutes-video-guide-314fb5a08111">CKAD: How to Create a network policy in 3 Minutes (Video Guide)</a> was originally published in <a href="https://blog.devgenius.io/">Dev Genius</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>