<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Bharath Adithya</title>
    <description>The latest articles on DEV Community by Bharath Adithya (@bharath_adithya).</description>
    <link>https://dev.to/bharath_adithya</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4100713%2F4b453590-fc4d-4e5f-b400-b414fe2b57aa.jpeg</url>
      <title>DEV Community: Bharath Adithya</title>
      <link>https://dev.to/bharath_adithya</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/bharath_adithya"/>
    <language>en</language>
    <item>
      <title>For anyone curious how Jev works, How LLMs Can Generate Structured JSON Without Generating It Token by Token</title>
      <dc:creator>Bharath Adithya</dc:creator>
      <pubDate>Tue, 22 Sep 2026 10:27:39 +0000</pubDate>
      <link>https://dev.to/bharath_adithya/for-anyone-curious-how-jev-works-how-llms-can-generate-structured-json-without-generating-it-token-5g9l</link>
      <guid>https://dev.to/bharath_adithya/for-anyone-curious-how-jev-works-how-llms-can-generate-structured-json-without-generating-it-token-5g9l</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"risk_level"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"HIGH"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"requires_review"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"action_tier"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"TIER_2"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Looks simple.&lt;/p&gt;

&lt;p&gt;But a standard autoregressive LLM typically generates that response &lt;strong&gt;token by token&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
   ↓
"risk_level"
   ↓
:
   ↓
"HIGH"
   ↓
,
   ↓
"requires_review"
   ↓
:
   ↓
true
   ↓
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every new token depends on the previous context.&lt;/p&gt;

&lt;p&gt;But what if the schema is already known?&lt;/p&gt;

&lt;p&gt;What if we already know that:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;risk_level     → HIGH | MEDIUM | LOW | NONE

requires_review → true | false

action_tier    → TIER_1 | TIER_2 | TIER_3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then generating every token of the JSON from scratch starts to look unnecessary.&lt;/p&gt;

&lt;p&gt;This is where an interesting approach to &lt;strong&gt;structured LLM inference&lt;/strong&gt; comes in.&lt;/p&gt;

&lt;h2&gt;
  
  
  🧠 The Core Idea
&lt;/h2&gt;

&lt;p&gt;Instead of asking the LLM to generate the complete JSON sequence, we can treat the problem more like &lt;strong&gt;classification over constrained choices&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The model receives:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Context + JSON Schema
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and the schema tells us what values are actually allowed.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;risk_level
├── HIGH
├── MEDIUM
├── LOW
└── NONE

requires_review
├── true
└── false

action_tier
├── TIER_1
├── TIER_2
└── TIER_3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now the model doesn't have to invent the structure.&lt;/p&gt;

&lt;p&gt;It only needs to determine:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Which valid value is most likely for each field?&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  ⚡ Step 1: Prefill the Context and Schema
&lt;/h2&gt;

&lt;p&gt;The first step is to process the context and JSON schema through the Transformer.&lt;/p&gt;

&lt;p&gt;Conceptually:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Context + Schema
       ↓
   Transformer
       ↓
    KV Cache
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the &lt;strong&gt;prefill phase&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;During this phase, the Transformer processes the input tokens and stores their &lt;strong&gt;keys and values&lt;/strong&gt; in the KV cache.&lt;/p&gt;

&lt;p&gt;The important part is that this information can be reused later.&lt;/p&gt;

&lt;p&gt;We don't want to repeatedly process the same context if we don't have to.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧩 Step 2: Reuse the KV Cache
&lt;/h2&gt;

&lt;p&gt;Now consider the individual fields.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;risk_level
requires_review
action_tier
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For each field, we can reuse the cached context and process the field-specific suffix.&lt;/p&gt;

&lt;p&gt;Conceptually:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;             KV Cache
                 │
       ┌─────────┼─────────┐
       ↓         ↓         ↓
  risk_level  requires_  action_tier
              review
       ↓         ↓         ↓
     Scores    Scores    Scores
       ↓         ↓         ↓
     HIGH      true      TIER_2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Instead of repeatedly starting from the entire context, the model can reuse information that has already been computed.&lt;/p&gt;




&lt;h2&gt;
  
  
  🎯 Step 3: Look Only at Valid Candidates
&lt;/h2&gt;

&lt;p&gt;A language model normally produces logits across its entire vocabulary.&lt;/p&gt;

&lt;p&gt;That could mean tens of thousands of possible tokens.&lt;/p&gt;

&lt;p&gt;But for:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;risk_level
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;we only care about:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HIGH
MEDIUM
LOW
NONE
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So why consider everything else?&lt;/p&gt;

&lt;p&gt;We can focus on the candidate tokens relevant to that field.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Full vocabulary
      ↓
Filter candidates
      ↓
HIGH
MEDIUM
LOW
NONE
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then the candidate scores can be converted into probabilities.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HIGH      → 0.9924
MEDIUM    → 0.0068
LOW       → 0.0006
NONE      → 0.0002
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The highest-probability valid candidate becomes the prediction:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HIGH
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  🔥 From Token Generation to Structured Prediction
&lt;/h2&gt;

&lt;p&gt;This changes the way we think about the task.&lt;/p&gt;

&lt;p&gt;Traditional LLM generation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Prompt
  ↓
Token
  ↓
Token
  ↓
Token
  ↓
Token
  ↓
Valid JSON
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Structured prediction:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Context + Schema
       ↓
    KV Cache
       ↓
 ┌─────┼─────┐
 ↓     ↓     ↓
 F1    F2    F3
 ↓     ↓     ↓
Score Score Score
 ↓     ↓     ↓
Value Value Value
 └─────┼─────┘
       ↓
   Valid JSON
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The model is no longer responsible for inventing every bracket, comma, quote, key, and value.&lt;/p&gt;

&lt;p&gt;The application already knows the structure.&lt;/p&gt;

&lt;p&gt;The model focuses on the &lt;strong&gt;semantic decision&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  🛡️ Another Big Advantage: Valid Structure
&lt;/h2&gt;

&lt;p&gt;One common problem with LLM-generated JSON is that the model can produce something like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"risk_level"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"VERY_HIGH"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"requires_review"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"maybe"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But our schema might only allow:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;risk_level
→ HIGH | MEDIUM | LOW | NONE

requires_review
→ true | false
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With constrained structured prediction, the candidate space itself can be restricted.&lt;/p&gt;

&lt;p&gt;That means the system isn't simply asking:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Please generate valid JSON."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It is enforcing the allowed structure around the model's prediction.&lt;/p&gt;

&lt;p&gt;Conceptually:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;LLM Vocabulary
      ↓
Schema Constraints
      ↓
Valid Candidates
      ↓
Probability Scores
      ↓
Selected Values
      ↓
Structured JSON
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This makes the output much more predictable.&lt;/p&gt;




&lt;h2&gt;
  
  
  🏗️ The Architecture
&lt;/h2&gt;

&lt;p&gt;A simplified architecture looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                 Input Document
                       │
                       ▼
                Context + Schema
                       │
                       ▼
               Transformer Decoder
                       │
                       ▼
                    KV Cache
                       │
          ┌────────────┼────────────┐
          ▼            ▼            ▼
      Field 1       Field 2      Field 3
          │            │            │
          ▼            ▼            ▼
    Candidates    Candidates    Candidates
          │            │            │
          ▼            ▼            ▼
       Logits        Logits        Logits
          │            │            │
          ▼            ▼            ▼
     Probabilities Probabilities Probabilities
          │            │            │
          └────────────┼────────────┘
                       ▼
                 Structured JSON
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The interesting part is the &lt;strong&gt;shared cached context&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  🚀 Why KV Caching Matters
&lt;/h2&gt;

&lt;p&gt;Imagine processing a large document.&lt;/p&gt;

&lt;p&gt;The model might need to extract:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;category
priority
risk_level
requires_review
action
confidence
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the same context is repeatedly processed from scratch, inference becomes unnecessarily expensive.&lt;/p&gt;

&lt;p&gt;With KV caching:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Context
   ↓
Transformer
   ↓
KV Cache
   ↓
Reuse
 ┌─┼─┼─┼─┼─┐
 ↓ ↓ ↓ ↓ ↓ ↓
F1 F2 F3 F4 F5 F6
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The expensive shared computation can be reused instead of recalculated for every field.&lt;/p&gt;

&lt;p&gt;This is one of the reasons &lt;strong&gt;KV caching is such an important concept in LLM inference engineering&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  📊 Where This Becomes Useful
&lt;/h2&gt;

&lt;p&gt;This approach becomes especially interesting when your output schema is predictable.&lt;/p&gt;

&lt;h3&gt;
  
  
  Document Intelligence
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"document_type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"INVOICE"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"priority"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"HIGH"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"requires_review"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Resume Analysis
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"experience_level"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"ENTRY"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"skill_match"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"HIGH"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"recommendation"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"SHORTLIST"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  AI Agents
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"tool"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"SEARCH"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"priority"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"HIGH"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"requires_confirmation"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Classification Pipelines
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"category"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"TECHNICAL"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"sentiment"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"POSITIVE"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"risk"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"LOW"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In all of these cases, the possible values can be known before inference begins.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧠 The Bigger AI Engineering Lesson
&lt;/h2&gt;

&lt;p&gt;This idea made me think about something important.&lt;/p&gt;

&lt;p&gt;When building LLM applications, we often ask:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;How can I make the model generate better?&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;But another question is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;How can I make the model generate less?&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Those are very different optimization strategies.&lt;/p&gt;

&lt;p&gt;Instead of:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Generate everything
       ↓
Parse JSON
       ↓
Validate
       ↓
Fix errors
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;we can move toward:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Define schema
       ↓
Constrain candidates
       ↓
Reuse cached context
       ↓
Score valid choices
       ↓
Build structured output
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The model handles the intelligence.&lt;/p&gt;

&lt;p&gt;The system handles the structure.&lt;/p&gt;




&lt;h2&gt;
  
  
  ⚙️ Traditional Generation vs Structured Inference
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Traditional
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Prompt
  ↓
LLM
  ↓
Token 1
  ↓
Token 2
  ↓
Token 3
  ↓
...
  ↓
JSON
  ↓
Validation
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Structured
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Context + Schema
       ↓
    Prefill
       ↓
    KV Cache
       ↓
Candidate Scoring
       ↓
Constrained Values
       ↓
Structured JSON
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The second approach shifts more responsibility from free-form generation to the inference and application layer.&lt;/p&gt;




&lt;h2&gt;
  
  
  🔬 The Part I Find Most Interesting
&lt;/h2&gt;

&lt;p&gt;The fascinating thing isn't just JSON.&lt;/p&gt;

&lt;p&gt;It's the underlying idea:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;A language model doesn't always need to behave like a text generator.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For some problems, it can behave more like a &lt;strong&gt;probabilistic decision engine operating inside a constrained space&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;That opens up interesting possibilities around:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;constrained decoding&lt;/li&gt;
&lt;li&gt;structured generation&lt;/li&gt;
&lt;li&gt;KV-cache reuse&lt;/li&gt;
&lt;li&gt;inference optimization&lt;/li&gt;
&lt;li&gt;efficient batching&lt;/li&gt;
&lt;li&gt;model serving&lt;/li&gt;
&lt;li&gt;structured prediction&lt;/li&gt;
&lt;li&gt;AI agent orchestration&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These are the kinds of details that become increasingly important when moving from simply &lt;strong&gt;using an LLM&lt;/strong&gt; to actually &lt;strong&gt;engineering LLM systems&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  💡 One Mental Model
&lt;/h2&gt;

&lt;p&gt;The simplest way I'm thinking about it now is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Traditional LLM

Understand
    ↓
Generate
    ↓
Generate
    ↓
Generate
    ↓
Validate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;versus:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Structured LLM Inference

Understand
    ↓
Reuse Context
    ↓
Restrict Choices
    ↓
Score Candidates
    ↓
Select
    ↓
Build Valid Output
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The model doesn't have to do everything.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Good AI engineering is often about deciding what the model should do — and what the system should handle instead.&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  🔥 Final Thought
&lt;/h2&gt;

&lt;p&gt;LLM inference is much more than:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Prompt → Model → Response
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Under the hood, concepts like:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Transformers → attention → KV cache → logits → softmax → constrained decoding → structured outputs&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;all contribute to how efficiently and reliably an AI system can operate.&lt;/p&gt;

&lt;p&gt;The more I explore this layer, the more I realize that building AI applications isn't only about choosing a powerful model.&lt;/p&gt;

&lt;p&gt;It's also about &lt;strong&gt;designing the inference process intelligently.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What other LLM inference optimization should I explore next?&lt;/strong&gt; 👇&lt;/p&gt;

&lt;h1&gt;
  
  
  AI #LLM #MachineLearning #GenerativeAI
&lt;/h1&gt;

</description>
      <category>ai</category>
      <category>opensource</category>
      <category>llm</category>
      <category>productivity</category>
    </item>
    <item>
      <title># 10 Git Commands That Made Me More Confident With Git</title>
      <dc:creator>Bharath Adithya</dc:creator>
      <pubDate>Sat, 29 Aug 2026 20:06:16 +0000</pubDate>
      <link>https://dev.to/bharath_adithya/-10-git-commands-that-made-me-more-confident-with-git-47h9</link>
      <guid>https://dev.to/bharath_adithya/-10-git-commands-that-made-me-more-confident-with-git-47h9</guid>
      <description>&lt;p&gt;If you've used Git for a while, you probably know the basics:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git add
git commit
git pull
git push
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These commands are enough to get started.&lt;/p&gt;

&lt;p&gt;But as your projects become bigger and you start working with branches, pull requests, conflicts, and other developers, Git starts getting a little more interesting.&lt;/p&gt;

&lt;p&gt;Here are &lt;strong&gt;10 Git commands and techniques that I found especially useful for moving beyond the basics.&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  1. &lt;code&gt;git merge&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Let's say you have a feature branch and the &lt;code&gt;main&lt;/code&gt; branch has received some new changes.&lt;/p&gt;

&lt;p&gt;You can bring those changes into your current branch using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git merge main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A simplified history might look like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;A---B---C main
     \
      D---E feature
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After merging:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;A---B---C------M
     \        /
      D---E---
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;M&lt;/code&gt; is the merge commit.&lt;/p&gt;

&lt;h3&gt;
  
  
  When is merge useful?
&lt;/h3&gt;

&lt;p&gt;Use merge when you want to preserve the branch history and clearly show that two lines of development were combined.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. &lt;code&gt;git rebase&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Rebase takes a different approach.&lt;/p&gt;

&lt;p&gt;Instead of creating a merge commit, Git moves your commits and reapplies them on top of another branch.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git rebase main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The previous history:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;A---B---C main
     \
      D---E feature
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;can become:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;A---B---C---D'---E'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The result is often easier to read.&lt;/p&gt;

&lt;p&gt;But there's an important thing to remember:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rebase rewrites commit history.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;So a simple rule is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Rebase your own local work carefully, especially before sharing it with others.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If you're rebasing a shared branch, you can create unnecessary problems for teammates.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. &lt;code&gt;git commit --amend&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Ever made a commit and immediately realized you forgot one small change?&lt;/p&gt;

&lt;p&gt;Instead of creating another unnecessary commit, you can add the change to the previous commit.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git add forgotten-file.js
git commit &lt;span class="nt"&gt;--amend&lt;/span&gt; &lt;span class="nt"&gt;--no-edit&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;--no-edit&lt;/code&gt; option keeps your previous commit message.&lt;/p&gt;

&lt;p&gt;If you also want to change the message:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git commit &lt;span class="nt"&gt;--amend&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Important
&lt;/h3&gt;

&lt;p&gt;Amending creates a new commit, which means the commit hash changes.&lt;/p&gt;

&lt;p&gt;So this is safest when the commit hasn't already been shared with other people.&lt;/p&gt;




&lt;h2&gt;
  
  
  4. &lt;code&gt;git push --force-with-lease&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Sometimes you rewrite your local history using:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;rebase&lt;/li&gt;
&lt;li&gt;amend&lt;/li&gt;
&lt;li&gt;interactive rebase&lt;/li&gt;
&lt;li&gt;squash&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Then a normal push may be rejected.&lt;/p&gt;

&lt;p&gt;You might be tempted to use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git push &lt;span class="nt"&gt;--force&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But there's a safer option:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git push &lt;span class="nt"&gt;--force-with-lease&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The difference is important.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;--force&lt;/code&gt; basically says:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Replace the remote branch with my version.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;code&gt;--force-with-lease&lt;/code&gt; checks whether the remote branch has changed before replacing it.&lt;/p&gt;

&lt;p&gt;That makes it a much safer choice when you actually need to force-push.&lt;/p&gt;




&lt;h2&gt;
  
  
  5. &lt;code&gt;git rebase -i&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;This is one of my favorite Git commands for cleaning up commits.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git rebase &lt;span class="nt"&gt;-i&lt;/span&gt; HEAD~5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This lets you interact with your last five commits.&lt;/p&gt;

&lt;p&gt;You'll see something similar to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pick a111111 Add login page
pick b222222 Add validation
pick c333333 Fix typo
pick d444444 Fix validation
pick e555555 Remove debug code
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can change &lt;code&gt;pick&lt;/code&gt; to commands such as:&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;pick&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Keep the commit as it is.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;reword&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Change only the commit message.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;edit&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Pause at that commit so you can modify it.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;squash&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Combine the commit with the previous one while keeping its commit message available for editing.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;fixup&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Combine the commit with the previous one and discard its commit message.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;drop&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Remove the commit.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pick   a111111 Add login page
fixup  b222222 Fix typo
fixup  c333333 Remove debug code
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;can turn several messy commits into a much cleaner history.&lt;/p&gt;




&lt;h2&gt;
  
  
  6. &lt;code&gt;git stash&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Imagine you're working on a feature and suddenly need to switch to another task.&lt;/p&gt;

&lt;p&gt;Your current code isn't ready to commit yet.&lt;/p&gt;

&lt;p&gt;That's where &lt;code&gt;git stash&lt;/code&gt; helps.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git stash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Git temporarily stores your uncommitted changes and gives you a clean working directory.&lt;/p&gt;

&lt;p&gt;You can then switch branches:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git switch main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Later, you can bring your changes back.&lt;/p&gt;

&lt;h3&gt;
  
  
  Include untracked files
&lt;/h3&gt;

&lt;p&gt;If you've also created new files:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git stash &lt;span class="nt"&gt;-u&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can even give your stash a useful name:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git stash push &lt;span class="nt"&gt;-u&lt;/span&gt; &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"WIP authentication feature"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To see your stashes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git stash list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To restore one:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git stash apply stash@&lt;span class="o"&gt;{&lt;/span&gt;0&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git stash pop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The simple difference:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apply = restore the changes
pop   = restore + remove the stash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  7. &lt;code&gt;git cherry-pick&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Sometimes you don't need an entire branch.&lt;/p&gt;

&lt;p&gt;You only need &lt;strong&gt;one specific commit&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;That's where cherry-pick comes in:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git cherry-pick &amp;lt;commit-hash&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git cherry-pick a1b2c3d
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Git takes the changes from that commit and applies them to your current branch.&lt;/p&gt;

&lt;p&gt;This is useful when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A bug fix exists on another branch&lt;/li&gt;
&lt;li&gt;You need one specific feature&lt;/li&gt;
&lt;li&gt;You don't want to merge the entire branch&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One important detail:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cherry-pick creates a new commit with a different hash.&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  8. &lt;code&gt;git reset&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;git reset&lt;/code&gt; is useful when you want to move your branch backwards.&lt;/p&gt;

&lt;p&gt;There are three common versions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git reset &lt;span class="nt"&gt;--soft&lt;/span&gt; HEAD~1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git reset &lt;span class="nt"&gt;--mixed&lt;/span&gt; HEAD~1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git reset &lt;span class="nt"&gt;--hard&lt;/span&gt; HEAD~1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The easiest way to remember them:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;--soft  → keep changes staged
--mixed → keep changes unstaged
--hard  → discard the changes
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For example:&lt;/p&gt;

&lt;h3&gt;
  
  
  Soft reset
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git reset &lt;span class="nt"&gt;--soft&lt;/span&gt; HEAD~1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Removes the last commit but keeps its changes staged.&lt;/p&gt;

&lt;h3&gt;
  
  
  Mixed reset
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git reset HEAD~1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Removes the last commit and keeps the changes in your working directory.&lt;/p&gt;

&lt;h3&gt;
  
  
  Hard reset
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git reset &lt;span class="nt"&gt;--hard&lt;/span&gt; HEAD~1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Moves the branch backwards and removes the changes from the working tree.&lt;/p&gt;

&lt;p&gt;⚠️ &lt;strong&gt;Be careful with &lt;code&gt;--hard&lt;/code&gt;.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Make sure you understand what you're about to discard before using it.&lt;/p&gt;




&lt;h2&gt;
  
  
  9. &lt;code&gt;git reflog&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;This command can be extremely useful when you think you've lost a commit.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git reflog
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;While &lt;code&gt;git log&lt;/code&gt; shows your reachable commit history, &lt;code&gt;reflog&lt;/code&gt; records movements of references such as &lt;code&gt;HEAD&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;You might see:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;e35fa12 HEAD@{0}: reset: moving to HEAD~2
821cd77 HEAD@{1}: commit: Add authentication
f992ab1 HEAD@{2}: commit: Add login page
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That previously "lost" commit may still be accessible.&lt;/p&gt;

&lt;p&gt;Instead of immediately resetting everything again, you can create a recovery branch:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git branch rescue 821cd77
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then inspect it safely.&lt;/p&gt;

&lt;h3&gt;
  
  
  Remember
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;reflog&lt;/code&gt; isn't a magic backup.&lt;/p&gt;

&lt;p&gt;If your work was never committed or otherwise stored by Git, reflog cannot recover it.&lt;/p&gt;




&lt;h2&gt;
  
  
  10. &lt;code&gt;git revert&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Here's an important situation.&lt;/p&gt;

&lt;p&gt;You pushed a commit to a shared branch, and that commit introduced a problem.&lt;/p&gt;

&lt;p&gt;Should you rewrite the branch history?&lt;/p&gt;

&lt;p&gt;Usually, &lt;strong&gt;no&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Instead, use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git revert &amp;lt;commit-hash&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Suppose your history is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;A---B---C
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And &lt;code&gt;C&lt;/code&gt; introduced the problem.&lt;/p&gt;

&lt;p&gt;Running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git revert C
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;creates another commit:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;A---B---C---D
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;D&lt;/code&gt; contains the opposite changes needed to undo &lt;code&gt;C&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The original commit remains visible in history.&lt;/p&gt;

&lt;p&gt;That's why &lt;code&gt;revert&lt;/code&gt; is generally a better choice for undoing changes on shared branches.&lt;/p&gt;




&lt;h1&gt;
  
  
  Quick Cheat Sheet
&lt;/h1&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Command&lt;/th&gt;
&lt;th&gt;Main purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;git merge&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Combine branch histories&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;git rebase&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Reapply commits on top of another branch&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;git commit --amend&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Modify the previous commit&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;git push --force-with-lease&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Safer force push&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;git rebase -i&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Clean up recent commits&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;git stash&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Temporarily save unfinished changes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;git cherry-pick&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Apply one specific commit&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;git reset&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Move branch history backwards&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;git reflog&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Find previous HEAD/reference states&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;git revert&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Safely undo a shared commit&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h1&gt;
  
  
  Final Thoughts
&lt;/h1&gt;

&lt;p&gt;Git becomes much easier once you stop thinking of it as just a collection of commands and start understanding &lt;strong&gt;what happens to your repository history after each command&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If you're currently learning Git, I'd recommend becoming comfortable with these first:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git stash
git merge
git rebase
git revert
git reset
git reflog
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then gradually add:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git rebase &lt;span class="nt"&gt;-i&lt;/span&gt;
git cherry-pick
git commit &lt;span class="nt"&gt;--amend&lt;/span&gt;
git push &lt;span class="nt"&gt;--force-with-lease&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The more you understand Git's history, the less scary those inevitable conflicts and mistakes become.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Which Git command has saved you the most time?&lt;/strong&gt; 👇&lt;/p&gt;

&lt;h1&gt;
  
  
  git #beginners #programming #webdev
&lt;/h1&gt;

</description>
      <category>ai</category>
      <category>programming</category>
      <category>beginners</category>
      <category>devops</category>
    </item>
  </channel>
</rss>
