<?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: AjeethKumar_Ramesh</title>
    <description>The latest articles on DEV Community by AjeethKumar_Ramesh (@iamajeeth).</description>
    <link>https://dev.to/iamajeeth</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%2F664861%2Fa7908d34-7028-4476-bba4-060c9283167c.jpeg</url>
      <title>DEV Community: AjeethKumar_Ramesh</title>
      <link>https://dev.to/iamajeeth</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/iamajeeth"/>
    <language>en</language>
    <item>
      <title>Taming Kafka Lag Spikes with KEDA Scale-to-Zero</title>
      <dc:creator>AjeethKumar_Ramesh</dc:creator>
      <pubDate>Sat, 15 Aug 2026 09:23:53 +0000</pubDate>
      <link>https://dev.to/iamajeeth/taming-kafka-lag-spikes-with-keda-scale-to-zero-epa</link>
      <guid>https://dev.to/iamajeeth/taming-kafka-lag-spikes-with-keda-scale-to-zero-epa</guid>
      <description>&lt;p&gt;&lt;em&gt;How we turned always-on Kafka sinks into on-demand workers that shrug off nightly bombardments — by scaling on the right signal, tuning per-pod drain rate, and keeping autoscaling from sabotaging itself.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Every number in this post is measured from a local lab you can run yourself — the full code is on &lt;a href="https://github.com/Ajeethkumar-r/kafka-lag-keda-lab" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;, and the Appendix has the commands.&lt;/p&gt;




&lt;h2&gt;
  
  
  The problem
&lt;/h2&gt;

&lt;p&gt;We run a fleet of Kafka &lt;strong&gt;sinks&lt;/strong&gt; — consumer services that read change events from Kafka, apply business logic, and write the result into a service-local database as a query-friendly materialized view. It keeps reads fast and independent from upstream systems, and it's a great pattern. But the workload has an awkward shape.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Most sinks are idle most of the day, then buried in minutes.&lt;/strong&gt; Traffic isn't steady: changes arrive in bursts, usually from nightly imports or CDC jobs. The rest of the day the topic is quiet.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;topic activity over 24h
  msgs ▲
       │              ██  nightly import / CDC burst
       │              ██
       │______________██______________  flat, idle ~22h/day
       └───────────────────────────────▶ time
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That shape creates &lt;strong&gt;two problems at once&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Idle waste.&lt;/strong&gt; When the topic is quiet, each sink still runs — it polls Kafka, holds connections, emits metrics, and occupies CPU and memory. Multiply one "small" sink across dozens of them and several regions, and you're paying around the clock for work that happens for a couple of hours a night.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Spike lag.&lt;/strong&gt; When the burst lands, a backlog builds fast. If consumers can't drain it quickly enough, &lt;strong&gt;consumer lag&lt;/strong&gt; — the gap between what's been produced and what's been processed — climbs, and downstream reads start serving stale data.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We want two things that sound contradictory: &lt;strong&gt;cost almost nothing when idle&lt;/strong&gt;, and &lt;strong&gt;absorb the spike fast&lt;/strong&gt; when it hits.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why the obvious autoscaler doesn't help
&lt;/h3&gt;

&lt;p&gt;The reflex is a Kubernetes Horizontal Pod Autoscaler (HPA) on CPU or memory. For sinks, that's the wrong signal.&lt;/p&gt;

&lt;p&gt;Sink work is &lt;strong&gt;I/O-bound&lt;/strong&gt;: the consumer spends its time waiting on Kafka polls and database writes, not burning CPU. So when a backlog builds, CPU stays &lt;em&gt;flat&lt;/em&gt; while lag climbs — and an HPA watching CPU concludes everything is fine and never scales.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;during a burst:
   lag   ▲  ███████   ← climbing fast (real work waiting)
   CPU   ▲  ▁▁▁▁▁▁▁   ← flat (blocked on I/O, not compute)
             → HPA sees low CPU, never scales, lag grows silently
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The question a sink autoscaler must answer isn't &lt;em&gt;"is this pod using CPU?"&lt;/em&gt; — it's &lt;strong&gt;"is there work waiting to be processed?"&lt;/strong&gt; The only signal that answers it directly is &lt;strong&gt;Kafka consumer lag&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;That reframes the whole solution. We need to scale on lag, we need each pod to actually drain fast, and we need scaling itself not to get in the way. Three moves.&lt;/p&gt;




&lt;h2&gt;
  
  
  The solution, in three moves
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Move 1 — Scale on lag, all the way to zero, with KEDA
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://keda.sh" rel="noopener noreferrer"&gt;KEDA&lt;/a&gt; (Kubernetes Event-Driven Autoscaling) lets Kubernetes scale on external signals — here, Kafka consumer-group lag — and, crucially, can scale a workload &lt;strong&gt;to zero&lt;/strong&gt;. A plain HPA can't go from one replica to zero; KEDA manages the HPA and the scale-to-zero around it.&lt;/p&gt;

&lt;p&gt;You describe the workload and the trigger in a &lt;code&gt;ScaledObject&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;keda.sh/v1alpha1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ScaledObject&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;sink-scaler&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;scaleTargetRef&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;StatefulSet&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;sink&lt;/span&gt;
  &lt;span class="na"&gt;minReplicaCount&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;            &lt;span class="c1"&gt;# scale-to-zero — the whole point&lt;/span&gt;
  &lt;span class="na"&gt;maxReplicaCount&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;12&lt;/span&gt;           &lt;span class="c1"&gt;# = partition count (see "The ceiling")&lt;/span&gt;
  &lt;span class="na"&gt;cooldownPeriod&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;60&lt;/span&gt;            &lt;span class="c1"&gt;# stay up until the backlog is fully drained&lt;/span&gt;
  &lt;span class="na"&gt;triggers&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;kafka&lt;/span&gt;
      &lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;bootstrapServers&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;hotel-cluster-kafka-bootstrap:9092&lt;/span&gt;
        &lt;span class="na"&gt;consumerGroup&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;foo-consumer-group&lt;/span&gt;
        &lt;span class="na"&gt;topic&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;hotel-topics&lt;/span&gt;
        &lt;span class="na"&gt;lagThreshold&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;1000"&lt;/span&gt;          &lt;span class="c1"&gt;# desired replicas ≈ totalLag / 1000&lt;/span&gt;
        &lt;span class="na"&gt;activationLagThreshold&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;0"&lt;/span&gt;   &lt;span class="c1"&gt;# wake from zero the instant lag appears&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;KEDA polls the lag, turns it into an autoscaling metric, and drives replicas roughly as &lt;code&gt;desiredReplicas ≈ totalLag / lagThreshold&lt;/code&gt;, capped at &lt;code&gt;maxReplicaCount&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What we measured.&lt;/strong&gt; Idle, the sink sits at &lt;strong&gt;0 replicas&lt;/strong&gt; — no pods, no cost. We fired a one-million-message burst and watched KEDA react:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;time&lt;/th&gt;
&lt;th&gt;replicas&lt;/th&gt;
&lt;th&gt;total lag&lt;/th&gt;
&lt;th&gt;what KEDA did&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;idle&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;scaled to zero — no pods, no cost&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;+6s&lt;/td&gt;
&lt;td&gt;12&lt;/td&gt;
&lt;td&gt;654,364&lt;/td&gt;
&lt;td&gt;saw lag, jumped straight to 12&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;+18s&lt;/td&gt;
&lt;td&gt;12&lt;/td&gt;
&lt;td&gt;357,452&lt;/td&gt;
&lt;td&gt;12 pods draining in parallel&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;+36s&lt;/td&gt;
&lt;td&gt;12&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;backlog cleared&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;~+96s&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;cooldown elapsed → back to zero&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;That &lt;code&gt;0 → 12 → 0&lt;/code&gt; cycle is the "always-on to on-demand" shift in one table: you pay for sink compute &lt;strong&gt;only when there's work&lt;/strong&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;One honest caveat about this run: all 12 pods wrote to a single shared database in the lab, which capped the &lt;em&gt;aggregate&lt;/em&gt; drain rate — so this isn't "12× one pod." The point here is the &lt;strong&gt;scaling shape&lt;/strong&gt; (zero → full → zero on lag). Per-pod throughput is a separate measurement, and it's where Move 2 comes in. (Scaling the write path itself is a topic for a follow-up post.)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Move 2 — More pods isn't enough: raise each pod's drain rate
&lt;/h3&gt;

&lt;p&gt;Here's the trap most KEDA write-ups skip: &lt;strong&gt;KEDA gives you pods, but a single pod's throughput is set by your consumer configuration.&lt;/strong&gt; If each pod drains slowly, a fleet of slow pods still drains slowly. We proved it by running the &lt;em&gt;same&lt;/em&gt; burst through the &lt;em&gt;same&lt;/em&gt; single consumer, twice — once naive, once tuned.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The naive baseline.&lt;/strong&gt; One database round-trip per record, one record per &lt;code&gt;poll()&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;NAIVE — one upsert per row, max.poll.records = 1
  ≈ 175 records/s per pod
  on a 40k burst: lag sits around ~37k, dropping only ~500 every 3 seconds
  a 1M backlog would take ≈ 1.5 hours
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The consumer isn't "busy" in CPU terms — it's just doing tiny, chatty units of work. Two changes fix that.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lever 1 — fetch fatter batches per poll.&lt;/strong&gt; Three consumer settings control how much a single &lt;code&gt;poll()&lt;/code&gt; returns:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;setting&lt;/th&gt;
&lt;th&gt;what it does&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;fetch.min.bytes&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;broker waits until it has at least this many bytes before replying&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;fetch.max.wait.ms&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;…but never waits longer than this (stays responsive when idle)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;max.poll.records&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;caps how many records one &lt;code&gt;poll()&lt;/code&gt; hands your code&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Under a flood, &lt;code&gt;fetch.min.bytes&lt;/code&gt; is satisfied instantly, so the broker returns a big batch and &lt;code&gt;max.poll.records&lt;/code&gt; lets your code process a fat chunk at once — far fewer, far larger round-trips.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lever 2 — write the whole batch in one transaction.&lt;/strong&gt; Instead of N single upserts, do one bulk, idempotent upsert per poll:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="n"&gt;materialized_view&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;updated_at&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;VALUES&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;now&lt;/span&gt;&lt;span class="p"&gt;()),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;now&lt;/span&gt;&lt;span class="p"&gt;()),&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt;          &lt;span class="c1"&gt;-- the entire poll() batch&lt;/span&gt;
&lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;CONFLICT&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;DO&lt;/span&gt; &lt;span class="k"&gt;UPDATE&lt;/span&gt;
  &lt;span class="k"&gt;SET&lt;/span&gt; &lt;span class="n"&gt;payload&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;EXCLUDED&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;updated_at&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;now&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;ON CONFLICT&lt;/code&gt; keeps it idempotent, so reprocessing after a rebalance is safe and can't corrupt the view.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The tuned result.&lt;/strong&gt; With the two levers on:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# the "after" consumer profile&lt;/span&gt;
&lt;span class="na"&gt;KAFKA_MAX_POLL_RECORDS&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;500"&lt;/span&gt;
&lt;span class="na"&gt;KAFKA_FETCH_MIN_BYTES&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;  &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;1048576"&lt;/span&gt;   &lt;span class="c1"&gt;# ~500 × 2KB → the broker returns a full batch&lt;/span&gt;
&lt;span class="na"&gt;SINK_BULK&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;              &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;true"&lt;/span&gt;       &lt;span class="c1"&gt;# one bulk upsert per poll&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;TUNED — same single consumer, same burst
  ≈ 19,000 records/s
  a 1M backlog drains in ≈ 50 seconds  (vs ≈ 1.5 hours naive)

   lag ▲  peak ╲
               ╲____
                    ╲______        same partitions, same single pod
   0  ─────────────────────╲_____▶  ~50s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's about &lt;strong&gt;100× the per-pod drain rate&lt;/strong&gt;, purely from reading fatter and writing in bulk — no extra pods. This is the lever KEDA can't pull for you. And since sinks are usually database-bound, batching the write is where most of the real gain lives.&lt;/p&gt;

&lt;h3&gt;
  
  
  Move 3 — Don't let scaling sabotage the drain: rebalances
&lt;/h3&gt;

&lt;p&gt;Now the subtle failure mode. When KEDA scales &lt;code&gt;1 → 6 → 12&lt;/code&gt; &lt;strong&gt;mid-burst&lt;/strong&gt;, every change in group membership triggers a Kafka &lt;strong&gt;consumer group rebalance&lt;/strong&gt; — a renegotiation of which consumer owns which partition. With the default &lt;em&gt;eager&lt;/em&gt; rebalancing, that's stop-the-world: every consumer gives up all its partitions, re-joins, and only then resumes. Consumption &lt;strong&gt;pauses across the whole group&lt;/strong&gt; exactly when you're trying to drain a spike, so scaling up can briefly make lag &lt;em&gt;worse&lt;/em&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;EAGER (default): add a pod → WHOLE group pauses → lag ticks up
   ▐███ pause ███▌ → reassign → resume
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two settings defuse it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cooperative rebalancing&lt;/strong&gt; makes a rebalance incremental — only the partitions that actually move pause; every other partition keeps being consumed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CooperativeStickyAssignor: add a pod → only moved partitions pause
   the rest keep draining the entire time
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Static membership&lt;/strong&gt; gives each pod a stable identity, so a restart (a rolling deploy, a node move) skips the rebalance entirely — as long as the pod returns within &lt;code&gt;session.timeout.ms&lt;/code&gt;. That needs a &lt;em&gt;stable&lt;/em&gt; pod name, which is why the sink runs as a &lt;strong&gt;StatefulSet&lt;/strong&gt; — its pods are named &lt;code&gt;sink-0&lt;/code&gt;, &lt;code&gt;sink-1&lt;/code&gt;, … and keep that ordinal across restarts:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# StatefulSet pod → stable ordinal name via the downward API&lt;/span&gt;
&lt;span class="na"&gt;env&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;POD_NAME&lt;/span&gt;
    &lt;span class="na"&gt;valueFrom&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;fieldRef&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;fieldPath&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;metadata.name&lt;/span&gt;      &lt;span class="c1"&gt;# sink-0, sink-1, … (survives a restart)&lt;/span&gt;
&lt;span class="c1"&gt;# consumer config:&lt;/span&gt;
&lt;span class="na"&gt;group.instance.id&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${POD_NAME}&lt;/span&gt;        &lt;span class="c1"&gt;# static member → a restart skips the rebalance&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add to those a scale-up policy that jumps to full width in one or two steps rather than climbing &lt;code&gt;1 → 2 → 3 → 4&lt;/code&gt; (each step is a rebalance), and a generous &lt;code&gt;cooldownPeriod&lt;/code&gt; so a draining burst doesn't make the fleet flap up and down. Now scaling &lt;em&gt;adds&lt;/em&gt; throughput instead of pausing it. (All four settings, with values, are in the config glossary below.)&lt;/p&gt;

&lt;h3&gt;
  
  
  The ceiling: you cannot outscale your partitions
&lt;/h3&gt;

&lt;p&gt;One hard limit ties it together. &lt;strong&gt;A Kafka partition is consumed by at most one consumer in a group.&lt;/strong&gt; If the topic has 12 partitions, the 13th pod gets no assignment and sits idle. So:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;effective max consumers ≤ number of partitions
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's why &lt;code&gt;maxReplicaCount&lt;/code&gt; is set to the partition count. If bursts are so large that 12 fully-tuned consumers still can't keep up, the fix is &lt;strong&gt;more partitions&lt;/strong&gt; (raising the ceiling) or a &lt;strong&gt;faster per-pod write path&lt;/strong&gt; — not more replicas. Once you've hit the ceiling, adding pods is pure waste:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;lag still climbing after replicas == partitions?
   → the bottleneck is no longer pods.
   → repartition, or make each pod drain faster — not more replicas.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Putting it together
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   nightly burst  ──▶  partitions fill  ──▶  lag rises
        │
        ▼
   ┌──────────────────────────────────────────────────────────────┐
   │ KEDA  (autoscaler)                                           │
   │   scales 0 → N on lag,  N ≤ partitions,  in big steps        │
   └──────────────────────────────────────────────────────────────┘
        │  + N pods
        ▼
   ┌──────────────────────────────────────────────────────────────┐
   │ CONSUMERS  (your config)                                     │
   │   fat polls: max.poll.records + fetch.min.bytes              │
   │   bulk idempotent upsert                                     │
   │   cooperative + static membership → scaling never pauses     │
   └──────────────────────────────────────────────────────────────┘
        │  drain rate = N × per-pod rate
        ▼
   lag peaks, then decays to 0  ──▶  cooldown  ──▶  KEDA scales to 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The system stays stable — lag bounded, then decaying — when &lt;code&gt;#partitions × per-pod-drain-rate &amp;gt; peak produce rate&lt;/code&gt;, &lt;strong&gt;and&lt;/strong&gt; you scale in few enough steps that rebalances don't eat the throughput you just added.&lt;/p&gt;




&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Scale on work, not on resource usage.&lt;/strong&gt; For event-driven sinks, consumer lag is the only signal that reflects real demand. CPU and memory stay flat while lag climbs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;KEDA gives you elasticity and scale-to-zero — not throughput.&lt;/strong&gt; A fleet of slow pods is still slow. Tune each pod: fatter polls, bulk idempotent writes. We saw about 100× the per-pod drain rate from tuning alone.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Don't let autoscaling pause the drain.&lt;/strong&gt; Cooperative rebalancing, static membership, and big scale-up steps keep consumption flowing while KEDA adds pods.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Respect the partition ceiling.&lt;/strong&gt; Consumers can't exceed partitions. Past that, repartition or speed up the write path — more replicas do nothing.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The net effect: a large set of always-on deployments became true on-demand workers — zero replicas when idle, a full-width tuned fleet within seconds of a burst, and lag that peaks and decays instead of climbing.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;In a follow-up post: what happens on the database side when all those consumers write at once — connection pooling, write throughput, and when to shard.&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Config glossary — every setting, and why it's there
&lt;/h2&gt;

&lt;p&gt;The settings fall into five groups, each doing a distinct job. Read it as: &lt;em&gt;autoscaling&lt;/em&gt; decides &lt;strong&gt;how many&lt;/strong&gt; pods, the &lt;em&gt;fetch&lt;/em&gt; and &lt;em&gt;write&lt;/em&gt; knobs decide &lt;strong&gt;how fast each one drains&lt;/strong&gt;, and the &lt;em&gt;rebalance&lt;/em&gt; knobs make sure scaling &lt;strong&gt;doesn't pause&lt;/strong&gt; that drain.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Autoscaling — how many pods (KEDA &lt;code&gt;ScaledObject&lt;/code&gt;)
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;setting&lt;/th&gt;
&lt;th&gt;lab value&lt;/th&gt;
&lt;th&gt;why it's there&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;minReplicaCount&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;0&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;enables scale-to-zero; this is what kills the idle-time cost&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;maxReplicaCount&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;12&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;caps replicas at the partition count — more pods can't get a partition (the ceiling)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;lagThreshold&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;1000&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;target lag per replica; &lt;code&gt;desiredReplicas ≈ totalLag / lagThreshold&lt;/code&gt; — lower = scale more aggressively&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;activationLagThreshold&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;0&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the wake-from-zero trigger; any lag at all brings up the first pod&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;cooldownPeriod&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;60s&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;how long to wait after lag clears before scaling down; stops the fleet flapping on a bursty topic&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;pollingInterval&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;10s&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;how often KEDA checks lag; smaller reacts faster, at more query load&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;scale-up &lt;code&gt;behavior&lt;/code&gt; policy&lt;/td&gt;
&lt;td&gt;big steps&lt;/td&gt;
&lt;td&gt;jump to full width in 1–2 steps instead of &lt;code&gt;1→2→3→4&lt;/code&gt; → fewer rebalances&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;fallback.replicas&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;1&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;if the lag metric is unavailable, hold this many pods instead of dropping to 0 (safety net)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  2. Fetch — how fat each &lt;code&gt;poll()&lt;/code&gt; is (consumer)
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;setting&lt;/th&gt;
&lt;th&gt;lab value&lt;/th&gt;
&lt;th&gt;why it's there&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;max.poll.records&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;500&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;records handed to your code per poll; sets the bulk-write batch size&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;fetch.min.bytes&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;1 MB&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;broker waits for this much data before replying → fewer, bigger round-trips under load&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;fetch.max.wait.ms&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;500&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;caps the wait above, so an idle topic still returns promptly&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  3. Write path — turn a fat batch into a cheap write (sink)
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;setting&lt;/th&gt;
&lt;th&gt;lab value&lt;/th&gt;
&lt;th&gt;why it's there&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;bulk upsert (multi-row &lt;code&gt;INSERT&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;on&lt;/td&gt;
&lt;td&gt;one transaction per poll instead of N single writes — the biggest per-pod gain&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ON CONFLICT DO UPDATE&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;on&lt;/td&gt;
&lt;td&gt;idempotency; safe to reprocess a batch after a rebalance without corrupting the view&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  4. Rebalance &amp;amp; stability — keep scaling from pausing the drain (consumer)
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;setting&lt;/th&gt;
&lt;th&gt;lab value&lt;/th&gt;
&lt;th&gt;why it's there&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;partition.assignment.strategy&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;CooperativeStickyAssignor&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;incremental rebalance; only moved partitions pause, the rest keep consuming&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;group.instance.id&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;pod name&lt;/td&gt;
&lt;td&gt;static membership; a pod restart skips the rebalance entirely&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;session.timeout.ms&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;45s&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;grace window a static member's partitions are held before reassignment on a restart&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;max.poll.interval.ms&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;300s&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;max time between polls before the broker evicts you; must exceed how long a batch takes to process&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  5. Topic — the parallelism ceiling (Kafka)
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;setting&lt;/th&gt;
&lt;th&gt;lab value&lt;/th&gt;
&lt;th&gt;why it's there&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;partitions&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;12&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;one consumer per partition, so this is the hard cap on useful consumers — size it for peak parallelism&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  Appendix — Reproduce it yourself
&lt;/h2&gt;

&lt;p&gt;The whole setup runs on a laptop: a local Kubernetes cluster (&lt;code&gt;kind&lt;/code&gt;), Kafka via Strimzi, real KEDA, a tunable Spring Kafka sink, and a live lag dashboard. No cloud account needed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prerequisites:&lt;/strong&gt; &lt;code&gt;docker&lt;/code&gt;, &lt;code&gt;kind&lt;/code&gt;, &lt;code&gt;kubectl&lt;/code&gt;, &lt;code&gt;helm&lt;/code&gt;, &lt;code&gt;java 17&lt;/code&gt;, &lt;code&gt;mvn&lt;/code&gt; (~6 GB of free RAM for Docker).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# 0. Get the code&lt;/span&gt;
git clone https://github.com/Ajeethkumar-r/kafka-lag-keda-lab.git
&lt;span class="nb"&gt;cd &lt;/span&gt;kafka-lag-keda-lab

&lt;span class="c"&gt;# 1. Stand up cluster + operators + build image + deploy (naive profile)&lt;/span&gt;
make up                          &lt;span class="c"&gt;# kind + Strimzi + KEDA + build + deploy (~5-8 min)&lt;/span&gt;

&lt;span class="c"&gt;# 2. Let KEDA drive replicas from lag&lt;/span&gt;
make keda-on

&lt;span class="c"&gt;# 3. Watch it live in a second terminal — http://localhost:8088&lt;/span&gt;
make dashboard                   &lt;span class="c"&gt;# lag, replicas, drain rate, ETA&lt;/span&gt;

&lt;span class="c"&gt;# 4. Fire a burst and watch the naive sink struggle (it stays stuck — no need to wait)&lt;/span&gt;
make burst &lt;span class="nv"&gt;NUM&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;1000000           &lt;span class="c"&gt;# 1M messages → lag climbs, drains slowly&lt;/span&gt;

&lt;span class="c"&gt;# 5. Switch to the tuned consumer and fire the SAME burst&lt;/span&gt;
make tuned
make burst &lt;span class="nv"&gt;NUM&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;1000000           &lt;span class="c"&gt;# lag peaks, then collapses; replicas 0 → 12 → 0&lt;/span&gt;

&lt;span class="c"&gt;# 6. Tear it all down&lt;/span&gt;
make down
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;What the dashboard shows:&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;NAIVE profile, after a burst:
  Consumers  0 → 12         (KEDA scaled up on lag)
  Total lag  climbs, drains ~175/s → stuck high for a long time
  Trend      ▲ climbing

TUNED profile, same burst:
  Consumers  0 → 12 → 0     (scaled up, drained, scaled back to zero)
  Total lag  peaks, drains ~19k/s → clears in under a minute
  Trend      ▼ draining
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Where each knob lives:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;concept&lt;/th&gt;
&lt;th&gt;file&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;scale-to-zero on lag&lt;/td&gt;
&lt;td&gt;&lt;code&gt;k8s/40-scaledobject.yaml&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;lagThreshold&lt;/code&gt; / &lt;code&gt;maxReplicaCount&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;&lt;code&gt;k8s/40-scaledobject.yaml&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;partitions = the ceiling&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;k8s/10-kafka.yaml&lt;/code&gt; (&lt;code&gt;partitions: 12&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;max.poll.records&lt;/code&gt; / &lt;code&gt;fetch.*&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;&lt;code&gt;k8s/32-sink-tuned.configmap.yaml&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;CooperativeStickyAssignor&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;k8s/32-sink-tuned.configmap.yaml&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;static membership (pod name)&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;k8s/30-sink.yaml&lt;/code&gt; (&lt;code&gt;POD_NAME&lt;/code&gt; via the downward API)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;bulk idempotent upsert&lt;/td&gt;
&lt;td&gt;&lt;code&gt;sink/.../SinkWriter.java&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Flip a single ConfigMap between the NAIVE and TUNED profiles, re-run the &lt;em&gt;same&lt;/em&gt; burst, and the difference in drain behavior shows up on the dashboard in real time.&lt;/p&gt;

</description>
      <category>kafka</category>
      <category>kubernetes</category>
      <category>keda</category>
      <category>devops</category>
    </item>
    <item>
      <title>Everything you need to know about Git</title>
      <dc:creator>AjeethKumar_Ramesh</dc:creator>
      <pubDate>Wed, 29 Dec 2021 13:34:25 +0000</pubDate>
      <link>https://dev.to/iamajeeth/everything-you-need-to-know-about-git-1fbf</link>
      <guid>https://dev.to/iamajeeth/everything-you-need-to-know-about-git-1fbf</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Move fast and break things. Unless you are breaking stuff, you are not moving fast enough. - &lt;em&gt;Mark Zuckerberg&lt;/em&gt;  &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Hope you all doing well, by the end of this post you will have complete knowledge to start with git and also familiar on it,&lt;/p&gt;

&lt;p&gt;⚡ &lt;strong&gt;Git&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;It is a version control tool in short this maintains your code history&lt;/em&gt;, you can take a real time scenario , Browser is a tool which stores your Browsing history&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Git Bash&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;we are going to use Git Bash which is a terminal, while installing git enable linux commands to get the full features. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;keep reading and you will know everything you need to know...&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Folder creation&lt;/strong&gt;&lt;br&gt;
Create a Newfolder give it a name as you like and open in Git Bash or you can go with Command propmt,&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp5jgb2db9sxe7ar9661r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp5jgb2db9sxe7ar9661r.png" alt=" " width="344" height="129"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;your bash will look something like this&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F30oha658dt9aoxxu9jwa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F30oha658dt9aoxxu9jwa.png" alt=" " width="491" height="68"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you are in command prompt make sure your are working in right directory.&lt;br&gt;
&lt;strong&gt;Initialize git repository&lt;/strong&gt;&lt;br&gt;
Initialize git in this folder &lt;code&gt;git init&lt;/code&gt;, it will create a empty repository in your local device&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsczojc4l7hh73mychigh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsczojc4l7hh73mychigh.png" alt=" " width="706" height="86"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;File creation&lt;/strong&gt;&lt;br&gt;
Create a new file and open it with vscode ,it is my opinion you can also do it with atom, sublime, it's completely up to you,  you will see master, It is a branch no need to worry about this now, I will explain in a while,&lt;br&gt;
To create a file in command prompt use &lt;code&gt;echo &amp;gt;fileName&lt;/code&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmtdb7n59o68qr9m79m85.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmtdb7n59o68qr9m79m85.png" alt=" " width="571" height="126"&gt;&lt;/a&gt;&lt;br&gt;
It will look similar to this,&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F84e3kn0ddtt12k8jr7r2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F84e3kn0ddtt12k8jr7r2.png" alt=" " width="551" height="82"&gt;&lt;/a&gt;&lt;br&gt;
Make some changes in the file and don't forget to save it&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2qzms3626gavmwkklo52.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2qzms3626gavmwkklo52.png" alt=" " width="508" height="115"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Clean terminal&lt;/strong&gt;&lt;br&gt;
sometimes we are the situation to make our bash looks clean, type &lt;code&gt;clear&lt;/code&gt; and hit enter. For command prompt use &lt;code&gt;cls&lt;/code&gt; and give enter&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqnvq9rn3c46h5enhttpf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqnvq9rn3c46h5enhttpf.png" alt=" " width="602" height="58"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Check status of commit&lt;/strong&gt;&lt;br&gt;
To check the status of our commits ,the info of file use &lt;code&gt;git status&lt;/code&gt; it will show you the file which is tracked or untracked, &lt;br&gt;
tracked denotes our file is staged and untracked denotes the file is not yet staged, Obviously we didn't commit anything so no commits will appear.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmhimncz88deyrk0sw0hu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmhimncz88deyrk0sw0hu.png" alt=" " width="700" height="266"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Eye and vision&lt;/strong&gt;&lt;br&gt;
Now the real part begins, to make our changes as a history there are two steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;staging the change&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;commit the change&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Stage&lt;/strong&gt;&lt;br&gt;
To bring our changes to the staging area use &lt;code&gt;git add .&lt;/code&gt;, you can replace period simple &lt;strong&gt;.&lt;/strong&gt; with your file name to be staged, generally the period simple includes all the changes in to staging area&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2mm1ayqk9m1a2mx5524b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2mm1ayqk9m1a2mx5524b.png" alt=" " width="631" height="60"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Commit&lt;/strong&gt;&lt;br&gt;
To commit the changes of the staged file use &lt;code&gt;git commit -m "your commit message"&lt;/code&gt; and it will show the number of changes and type of changes that are insertion or deletion to the file&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F20i54r8qth5sumait1vn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F20i54r8qth5sumait1vn.png" alt=" " width="597" height="119"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;This is similar to photo taking scenario in marriage reception, the people who want to take photo should come to stage , after taking photo it will save in the marriage album, &lt;strong&gt;changes we need to save as history should be staged first and then commit .&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Again we check our status it show you working tree clean , &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl8kaj2jvrwxb3yyaabgm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl8kaj2jvrwxb3yyaabgm.png" alt=" " width="601" height="92"&gt;&lt;/a&gt;&lt;br&gt;
Create another file and make changes check the status &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvmha8gn1nwtdpvvpfl73.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvmha8gn1nwtdpvvpfl73.png" alt=" " width="700" height="202"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;stage the changes &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8wwdfg7fjxlrptnltw93.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8wwdfg7fjxlrptnltw93.png" alt=" " width="619" height="70"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Dump area&lt;/strong&gt;&lt;br&gt;
Type &lt;code&gt;git stash&lt;/code&gt;, check the status of your commits again , it shows &lt;em&gt;nothing to commit working tree clean&lt;/em&gt;, &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3tyv5ohp67hpr4mmjs7f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3tyv5ohp67hpr4mmjs7f.png" alt=" " width="702" height="211"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Take a realtime scenario, if you are working on some kind of logical code in project and you commit the changes that might have issues, so you decide not to lose the changes but also keep it for future purpose. &lt;br&gt;
We use &lt;code&gt;git stash&lt;/code&gt;, stash is a hidden place where we can store our commits until it really needs.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Incase now you need the commits from stash area now, we need to bring it in staging area again using &lt;code&gt;git stash pop&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm0fgdlo8quu2s0iicak7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm0fgdlo8quu2s0iicak7.png" alt=" " width="688" height="178"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Now we can commit those changes and check status of our commits if you want, &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F86rz1bxypykaidqgh8n4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F86rz1bxypykaidqgh8n4.png" alt=" " width="604" height="122"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To see all the commits which are recorded as history use &lt;code&gt;git log&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu3j949e9lupp3by7wxmk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu3j949e9lupp3by7wxmk.png" alt=" " width="682" height="279"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;so far you are doing great !!!&lt;/em&gt; &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Host on Github&lt;/strong&gt;&lt;br&gt;
To add our local folder or a local repository to Github, there are two steps&lt;/p&gt;

&lt;p&gt;1.Create a Repository&lt;br&gt;
2.Add local repo to github &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Github&lt;/strong&gt;&lt;br&gt;
To create a new repository on github, repository(repo) is simply a storage area of all our file along with the commits respectively.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Create Repository&lt;/strong&gt;&lt;br&gt;
For creating a repo you should have an account in github, so signUp and then follow along with me, if you already have an account login to your account , go to repository click new.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fla0eonei3hlxl6sr6j6v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fla0eonei3hlxl6sr6j6v.png" alt=" " width="798" height="106"&gt;&lt;/a&gt;&lt;br&gt;
Give a name for your repo and click Create repository&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs7ym699kg17dbhxqhv9m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs7ym699kg17dbhxqhv9m.png" alt=" " width="630" height="509"&gt;&lt;/a&gt;&lt;br&gt;
and now your screen will appear like this, github show you the steps here we need last two steps , because already we did up to commit, &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiqvr3wvj8gr2tb4uj1mo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiqvr3wvj8gr2tb4uj1mo.png" alt=" " width="799" height="260"&gt;&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Add local repo to github&lt;/strong&gt;&lt;br&gt;
Need to copy HTTPS or SSH link and work on it, word remote denotes you are working with URL, origin is basically  your github account.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc3ih0e2dkurqs12lmvyo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc3ih0e2dkurqs12lmvyo.png" alt=" " width="698" height="77"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To push the changes that we made in our local repo to github main repo&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fopsiqrzw2irf5o6p0knl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fopsiqrzw2irf5o6p0knl.png" alt=" " width="698" height="242"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now go to github tab and refresh the browser and the magic happens, you are able to see the changes that we made in our local repo in main repo&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdlxvnufv0a3mcwjtmqby.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdlxvnufv0a3mcwjtmqby.png" alt=" " width="800" height="157"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Restore commits&lt;/strong&gt;&lt;br&gt;
Change something in file1 or file2 and stage the change , now if we want to restore changes we made stage it and check status&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6rv8tposncrkl86fgiwp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6rv8tposncrkl86fgiwp.png" alt=" " width="609" height="234"&gt;&lt;/a&gt;&lt;br&gt;
and now use &lt;code&gt;git restore --staged fileName&lt;/code&gt; , leave &lt;code&gt;--staged&lt;/code&gt; flag to restore local changes too and check status&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy39madjupc0ukhoysjrb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy39madjupc0ukhoysjrb.png" alt=" " width="704" height="302"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Remove file&lt;/strong&gt;&lt;br&gt;
To remove the file from working tree use &lt;code&gt;git rm --cached fileName&lt;/code&gt;and check status&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxonyx5j1am5lh8wcfcef.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxonyx5j1am5lh8wcfcef.png" alt=" " width="682" height="344"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Tip&lt;/strong&gt;&lt;br&gt;
Stage the file, commit it and check status, it shows your branch is ahead of origin/master by 1 commit and inform us to push local commits, whenever these kind of situation happens do as your command line said. I know that's a lot, move forward you need few more concepts to complete.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fay14gd9a7lsde4jnjun4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fay14gd9a7lsde4jnjun4.png" alt=" " width="606" height="160"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As the status shows we need to push the changes and check status  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9igoia3ajy8vbuvo0k3s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9igoia3ajy8vbuvo0k3s.png" alt=" " width="563" height="360"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Hosting on github&lt;/strong&gt;&lt;br&gt;
Go to your browser and refresh, you will be amazed, give an applause to yourself. Note the commit &lt;strong&gt;&lt;em&gt;back to normal&lt;/em&gt;&lt;/strong&gt; that is pushed from our local branch.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg07s26xjoi2phl1xdv1c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg07s26xjoi2phl1xdv1c.png" alt=" " width="798" height="167"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Create another file make some changes, stage that and commit&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm0vbini09uyo906zjgr8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm0vbini09uyo906zjgr8.png" alt=" " width="635" height="238"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Commit records&lt;/strong&gt;&lt;br&gt;
See all the commit messages using &lt;code&gt;git log&lt;/code&gt;.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frd7zd4ghvnkzjd0ep343.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frd7zd4ghvnkzjd0ep343.png" alt=" " width="661" height="516"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Structure of Commit messages&lt;/strong&gt;:&lt;br&gt;
Commit messages are align on &lt;em&gt;top of one another&lt;/em&gt;, To delete commit messages you need to pick the commitID and paste in &lt;code&gt;git reset commitID&lt;/code&gt;, this will delete all the commits above the one which you pick.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Commit messages are like a bread slices&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzguix8tijdwz7xn87c4z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzguix8tijdwz7xn87c4z.png" alt=" " width="668" height="445"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I want this to be clean and understandable , for that delete file3.txt in my case , you may leave it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhnyrpjmb5gw5ltmbo3wy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhnyrpjmb5gw5ltmbo3wy.png" alt=" " width="583" height="367"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To push our changes to github main repo &lt;code&gt;git push origin master&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyhtolcx1q487e08j76ju.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyhtolcx1q487e08j76ju.png" alt=" " width="634" height="230"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pointer&lt;/strong&gt;&lt;br&gt;
It's time to know &lt;em&gt;HEAD&lt;/em&gt;, this is simply a pointer which points to the active branch , you will understand more in a bit.&lt;br&gt;
&lt;strong&gt;Branch&lt;/strong&gt;&lt;br&gt;
Now we are going to work on branches, to create a branch use &lt;code&gt;git branch branchName&lt;/code&gt; and checkout this branch by &lt;code&gt;git checkout branchName&lt;/code&gt;, after checking out the HEAD is now point to the new branchName, here after the commits we will made is from branchName&lt;/p&gt;

&lt;p&gt;Create new branch , checkout then create a file and change something ,stage it and commit &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7tlvyxsnetaqkst153y1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7tlvyxsnetaqkst153y1.png" alt=" " width="626" height="375"&gt;&lt;/a&gt;&lt;br&gt;
Make some more commits may be two is good to go and &lt;code&gt;git log&lt;/code&gt; now&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm8lckpdue17g4ibmsuvh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm8lckpdue17g4ibmsuvh.png" alt=" " width="681" height="647"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;we need to push our change in local branch to github&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fot5epsup1379z6mv6jfr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fot5epsup1379z6mv6jfr.png" alt=" " width="670" height="360"&gt;&lt;/a&gt; &lt;br&gt;
&lt;strong&gt;Newbie&lt;/strong&gt;-our branch will be on github&lt;br&gt;
Now your github screen automatically shows you &lt;em&gt;Compare &amp;amp; pull request&lt;/em&gt; , click on that&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1rod8nhxxx67t0zjnzel.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1rod8nhxxx67t0zjnzel.png" alt=" " width="799" height="242"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now click on &lt;em&gt;create pull request&lt;/em&gt; it will show you&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyf66ijib4stkpx5nj8ah.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyf66ijib4stkpx5nj8ah.png" alt=" " width="799" height="403"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Merge conflict&lt;/strong&gt;&lt;br&gt;
Here if there is no conflict on your change can simply click on &lt;em&gt;Merge pull request&lt;/em&gt;, conflict is popularly known as &lt;em&gt;merge conflict&lt;/em&gt; , assume that two persons working on same change and commit it, github doesn't know which change to take in this case we manually make the change on github and then we are allowed &lt;br&gt;
merge pull request &lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2wy4pk8sjb43haxpndpc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2wy4pk8sjb43haxpndpc.png" alt=" " width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I know we are doing tons of things but it's worth&lt;/em&gt; . &lt;br&gt;
Now click confirm merge, there you can delete the branch if it is no longer needed &lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft6o1d31fmhi3mxcvd9l3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft6o1d31fmhi3mxcvd9l3.png" alt=" " width="800" height="179"&gt;&lt;/a&gt;&lt;br&gt;
Go to your code now and refresh the page you can see there will second branch and the file along with it's commit &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5ojaya19syy4onmmn7pm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5ojaya19syy4onmmn7pm.png" alt=" " width="800" height="203"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Hope you feel confidence on yourself&lt;/em&gt; .&lt;br&gt;
&lt;strong&gt;Rebase&lt;/strong&gt;- new base&lt;br&gt;
There is a little more to do , for that need some changes in master branch may be three commits are good to go , now &lt;code&gt;git log&lt;/code&gt;, In sometimes we need to reduce number of commits as one commit, assume that you are working in login form of your project you will commit each changes and push it, those commits are points to single work so we squash all three to one commit, here we use &lt;code&gt;git rebase&lt;/code&gt;, before that we need to  pick the commit id , this has same hierarchy as &lt;code&gt;git reset&lt;/code&gt; &lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fopnxjao84ngvpl9e8ix6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fopnxjao84ngvpl9e8ix6.png" alt=" " width="678" height="361"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;use this command &lt;code&gt;git rebase -i CommitID&lt;/code&gt;, &lt;em&gt;i&lt;/em&gt; is interactive most of the time we need -i flag, give enter this will show you like this&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkegqv25fdrfrwy19cnpp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkegqv25fdrfrwy19cnpp.png" alt=" " width="688" height="288"&gt;&lt;/a&gt; &lt;br&gt;
&lt;strong&gt;Squash&lt;/strong&gt;&lt;br&gt;
you can see that &lt;em&gt;Pick&lt;/em&gt; and &lt;em&gt;s&lt;/em&gt; ,we don't need to change the first pick it remains same, now if we want to squash the commit we change it to &lt;em&gt;s&lt;/em&gt;, at least the commits should have one pick ,the &lt;em&gt;s&lt;/em&gt; commits combine with the nearest &lt;em&gt;pick&lt;/em&gt; commit , it doesn't matter how many commits to be squashed , you should have one &lt;em&gt;pick&lt;/em&gt; which will be above &lt;em&gt;s&lt;/em&gt; commit . To know more you can refer &lt;a href="https://www.atlassian.com/git/tutorials/rewriting-history/git-rebase" rel="noopener noreferrer"&gt;&lt;/a&gt;, to type in this click &lt;em&gt;i&lt;/em&gt;. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe4llsj1326fa2v5hc45t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe4llsj1326fa2v5hc45t.png" alt=" " width="688" height="288"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp10j3gwailyzkj1veqid.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp10j3gwailyzkj1veqid.png" alt=" " width="609" height="103"&gt;&lt;/a&gt;&lt;br&gt;
By default Vim is the text editor for git, this below lines will help the non vim users, &lt;br&gt;
to escape from vim editor click &lt;code&gt;ESC&lt;/code&gt;, colon &lt;code&gt;:&lt;/code&gt; and &lt;code&gt;x&lt;/code&gt; after that you have screen like this &lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft6uvo205g0ivum8q2w72.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft6uvo205g0ivum8q2w72.png" alt=" " width="693" height="371"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;remove the &lt;em&gt;#&lt;/em&gt; which is used to comment the line then type you commit message, after that click &lt;em&gt;ESC&lt;/em&gt; , &lt;em&gt;:&lt;/em&gt; and &lt;em&gt;x&lt;/em&gt; to exit edit mode&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh5ltmx1tyo6sfn5t46oi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh5ltmx1tyo6sfn5t46oi.png" alt=" " width="591" height="372"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;we &lt;em&gt;finished rebasing&lt;/em&gt; now time to push it to github&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmpkkrpsv89dq6ko0ii9a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmpkkrpsv89dq6ko0ii9a.png" alt=" " width="586" height="167"&gt;&lt;/a&gt;&lt;br&gt;
here is the Squashed commit&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx3euda70li8m1wzq9an2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx3euda70li8m1wzq9an2.png" alt=" " width="618" height="261"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Go to github now you can see the change in commit message&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs40qxl3mqyt0d642d593.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs40qxl3mqyt0d642d593.png" alt=" " width="799" height="276"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;git push&lt;/code&gt; -push the changes along with commit messages.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git fetch&lt;/code&gt; -fetch the recent commit messages. &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git pull&lt;/code&gt; -pull the code with commit messages, it internally operate &lt;em&gt;git fetch&lt;/em&gt; .&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To know more you can refer &lt;a href="https://www.atlassian.com/git" rel="noopener noreferrer"&gt;git atlassian&lt;/a&gt;&lt;/p&gt;




&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Learning never fulfilled untill you practice on your own and share it with other people&lt;/em&gt; . &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Alright now you can add &lt;strong&gt;git&lt;/strong&gt; skill in profile and be happy for what you have done by reading this post. &lt;/p&gt;

</description>
      <category>git</category>
      <category>github</category>
      <category>beginners</category>
    </item>
    <item>
      <title>querySelector() and querySelectorAll()</title>
      <dc:creator>AjeethKumar_Ramesh</dc:creator>
      <pubDate>Wed, 28 Jul 2021 04:01:11 +0000</pubDate>
      <link>https://dev.to/iamajeeth/queryselector-and-queryselectorall-57oi</link>
      <guid>https://dev.to/iamajeeth/queryselector-and-queryselectorall-57oi</guid>
      <description>&lt;p&gt;Let me explain the most basics of querySelector() by name. &lt;/p&gt;

&lt;p&gt;Don't skip while reading these lines&lt;/p&gt;

&lt;p&gt;$-CREATIVE EXPLANATION:&lt;/p&gt;

&lt;p&gt;Generally querySelector() and querySelectorAll() from same family which is "API".&lt;/p&gt;

&lt;p&gt;query: His most popular name is "question", he is a toddler in API family &lt;/p&gt;

&lt;p&gt;Selector: She is the mother of our toddler(query), without her(Selector) query don't know how to work or what to do.&lt;/p&gt;

&lt;p&gt;If you understand the pretty lines above go ahead to read  real concept,&lt;/p&gt;

&lt;p&gt;$-SUBJECT:&lt;/p&gt;

&lt;p&gt;querySelector(): To get the particular element from your html document,and make fancy using css or you can use it in your js codes, Which only select the first instance of the element.&lt;/p&gt;

&lt;p&gt;querySelectorAll(): Only difference between querySelector() and querySelectorAll() is it(querySelectorAll()) can select as many as instances specifically a particular group of elements having same name (.classNames) or by the tags(h1,p,div etc.,)&lt;/p&gt;

&lt;p&gt;This is my first blog, I hope it has little fun with explaining concept, //if it has any mistakes feel free to comment. &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>css</category>
      <category>html</category>
    </item>
  </channel>
</rss>
