<?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: Shane Dsouza</title>
    <description>The latest articles on DEV Community by Shane Dsouza (@shanedsouza4).</description>
    <link>https://dev.to/shanedsouza4</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3066918%2Fbe58e3bd-535a-4911-a842-eb277de8da0f.jpg</url>
      <title>DEV Community: Shane Dsouza</title>
      <link>https://dev.to/shanedsouza4</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/shanedsouza4"/>
    <language>en</language>
    <item>
      <title>Prompting Techniques: How to Talk to AI (and Get What You Want)</title>
      <dc:creator>Shane Dsouza</dc:creator>
      <pubDate>Mon, 14 Jul 2025 04:19:06 +0000</pubDate>
      <link>https://dev.to/shanedsouza4/prompting-techniques-how-to-talk-to-ai-and-get-what-you-want-5f9e</link>
      <guid>https://dev.to/shanedsouza4/prompting-techniques-how-to-talk-to-ai-and-get-what-you-want-5f9e</guid>
      <description>&lt;p&gt;If you've ever used AI models like ChatGPT or Claude, you’ve probably noticed that the way you ask a question changes everything. It’s not just &lt;em&gt;what&lt;/em&gt; you ask, it’s &lt;em&gt;how&lt;/em&gt; you ask it. That’s where knowing how to prompt comes into play.&lt;/p&gt;

&lt;p&gt;In the world of Large Language Models (LLMs), the concept of &lt;strong&gt;“Garbage In, Garbage Out” (GIGO)&lt;/strong&gt; still holds true. If your input is unclear or confusing, the output will be too. But when you give good instructions, you usually get good results.&lt;/p&gt;

&lt;p&gt;In this post, we’ll look at some common prompting techniques that can help you get better results when interacting with LLMs.&lt;/p&gt;




&lt;h2&gt;
  
  
  Prompting Techniques
&lt;/h2&gt;

&lt;p&gt;Now that we understand the importance of clear instructions, let’s look at a few prompting techniques that can make a big difference. These simple methods help guide the model more effectively and improve the quality of the responses you get.&lt;/p&gt;




&lt;h3&gt;
  
  
  1. Zero-Shot Prompting
&lt;/h3&gt;

&lt;p&gt;You ask the model to do something &lt;strong&gt;without giving any examples&lt;/strong&gt;.&lt;/p&gt;

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

&lt;blockquote&gt;
&lt;p&gt;Generate a strong password using letters, numbers, and symbols.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Even though you didn’t show it how to make a password, the model understands and can create one for you.&lt;/p&gt;




&lt;h3&gt;
  
  
  2. Few-Shot Prompting
&lt;/h3&gt;

&lt;p&gt;Here you give the model a &lt;strong&gt;few examples&lt;/strong&gt; of what you want before asking it to do the task. This helps the model understand the style and how it should respond.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prompt Setup:&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;You are an AI expert in Mathematics. You only solve math problems.  
If a user asks anything outside of math, politely let them know you can’t help with that.

Examples:
User: 8 + 4
Assistant: 8 + 4 = 12. By adding 8 with 4 we get 12.

User: 2 * 3
Assistant: 2 * 3 = 6. By multiplying 2 with 3, we get 6.

User: How to make tea?
Assistant: Sorry, I am just a Mathematics expert. I can only help with math problems.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  3. Chain-of-Thought Prompting
&lt;/h3&gt;

&lt;p&gt;Here, you guide the model to &lt;strong&gt;think step by step&lt;/strong&gt; before responding, instead of jumping straight to the final answer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prompt Setup:&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;You are a helpful AI assistant who is specialized in resolving user queries.  
For the given user input, analyze the problem and break it down step by step.

The thinking process goes like this:
1. Analyse: Understand what the question is about  
2. Think: Start thinking through the steps  
3. Output: Give a direct answer  
4. Validate: Double check your logic  
5. Result: Present the final result with a brief explanation

Example:
User: What is 2 + 2
Output: { "step": "analyse", "content": "Alright! The user is asking a basic arithmetic question." }
Output: { "step": "think", "content": "To perform this addition, I must add 2 and 2." }
Output: { "step": "output", "content": "4" }
Output: { "step": "validate", "content": "Seems like 4 is the correct answer for 2 + 2." }
Output: { "step": "result", "content": "2 + 2 = 4, and this is calculated by adding both numbers." }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This style helps the model reason more clearly and avoid careless mistakes. It works well for logical or step-by-step problems.&lt;/p&gt;




&lt;h3&gt;
  
  
  4. Self-Consistency Prompting
&lt;/h3&gt;

&lt;p&gt;With this technique, you ask the model the &lt;strong&gt;same question multiple times&lt;/strong&gt; and compare the answers. The goal is to find the response that shows up most often or makes the most sense.&lt;/p&gt;

&lt;p&gt;LLMs don’t always give the same answer every time you ask. They may follow different paths of thinking. Sometimes the first answer is right, sometimes it isn’t.&lt;/p&gt;

&lt;p&gt;Self-consistency lets the model "think again," and you choose the answer that’s most consistent or reliable.&lt;/p&gt;

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

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; Should I use dark mode or light mode on my phone?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You ask the model 3–5 times:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Try 1:&lt;/strong&gt; Dark mode is easier on the eyes. → &lt;strong&gt;Answer:&lt;/strong&gt; Dark mode
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Try 2:&lt;/strong&gt; Dark mode saves battery and looks better at night. → &lt;strong&gt;Answer:&lt;/strong&gt; Dark mode
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Try 3:&lt;/strong&gt; Light mode is bright but can cause strain. Dark mode is better. → &lt;strong&gt;Answer:&lt;/strong&gt; Dark mode&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Since &lt;strong&gt;“Dark mode”&lt;/strong&gt; is the most common answer, you go with that.&lt;/p&gt;




&lt;h3&gt;
  
  
  5. Persona-Based Prompting
&lt;/h3&gt;

&lt;p&gt;Here you ask the model to take on a &lt;strong&gt;specific role or identity&lt;/strong&gt; before answering any questions. This sets the tone, language, and point of view in the response.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prompt Setup:&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;You are a local travel guide from Toronto. 
You speak in a welcoming, helpful tone and give practical tips for visitors.

Example:
User: I’m visiting Toronto for the first time. What should I do in one day?

Assistant: Welcome to Toronto. If you’ve only got one day, here’s how to make the most of it.
Start your day at the CN Tower for amazing city views. Then walk along the Harbourfront to enjoy the lake.
In the afternoon, explore the Distillery District for local shops and history.
End your day at Polson Pier, it’s the perfect spot to catch the sunset.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;If there's one key takeaway from this post, it's this:&lt;br&gt;&lt;br&gt;
&lt;strong&gt;The way you talk to an AI makes all the difference.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It’s not magic. It’s communication.&lt;br&gt;&lt;br&gt;
And like any great conversation, it depends on &lt;strong&gt;tone&lt;/strong&gt;, &lt;strong&gt;context&lt;/strong&gt;, and &lt;strong&gt;clarity&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The better your prompt, the better the output.&lt;br&gt;
Try using these techniques in your next chat with an AI and see the difference for yourself.&lt;br&gt;&lt;br&gt;
Want to go deeper? Try combining techniques, like &lt;strong&gt;persona-based + chain-of-thought&lt;/strong&gt;, to get even better results.&lt;/p&gt;

&lt;p&gt;Enjoyed this post?&lt;br&gt;
Found it helpful? Feel free to leave a comment, share it with your team, or follow along for more.&lt;/p&gt;

&lt;p&gt;🌐 &lt;a href="https://shanedsouza.com/" rel="noopener noreferrer"&gt;shanedsouza.com&lt;/a&gt;&lt;/p&gt;

</description>
      <category>chatgpt</category>
      <category>ai</category>
      <category>promptengineering</category>
      <category>openai</category>
    </item>
    <item>
      <title>AI Buzzwords Decoded: What LLMs like ChatGPT Really Do</title>
      <dc:creator>Shane Dsouza</dc:creator>
      <pubDate>Fri, 11 Jul 2025 01:57:31 +0000</pubDate>
      <link>https://dev.to/shanedsouza4/ai-buzzwords-decoded-what-llms-really-do-15hi</link>
      <guid>https://dev.to/shanedsouza4/ai-buzzwords-decoded-what-llms-really-do-15hi</guid>
      <description>&lt;p&gt;Many of us use AI tools like ChatGPT or GitHub Copilot in our daily lives, but what actually powers them? If you've ever tried to read up on AI, you've probably run into terms like &lt;strong&gt;tokenization&lt;/strong&gt;, &lt;strong&gt;embeddings&lt;/strong&gt;, and &lt;strong&gt;transformers&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Sounds complicated? It doesn’t have to be.&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%2Fo7o3wuks3djycbmwjhw0.jpeg" 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%2Fo7o3wuks3djycbmwjhw0.jpeg" alt=" " width="200" height="188"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Welcome to the world of AI, where tech buzzwords pop up faster than autocomplete suggestions. In this article, I’ll break down several AI jargon into simple concepts.&lt;/p&gt;




&lt;h2&gt;
  
  
  LLMs
&lt;/h2&gt;

&lt;p&gt;LLM stands for &lt;strong&gt;Large Language Model&lt;/strong&gt;, a type of AI trained to understand and generate human language. It takes in human text as input, processes it, and then produces a response that makes sense to us.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;ChatGPT is one of the most popular LLMs, created by OpenAI and made accessible to the public.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  GPT
&lt;/h2&gt;

&lt;p&gt;GPT stands for &lt;strong&gt;Generative Pre-trained Transformer&lt;/strong&gt;. Let's break that down:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Generative&lt;/strong&gt;: It generates content like text, code, or even images.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pre-trained&lt;/strong&gt;: It has already learned from huge amounts of data before being used.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Transformer&lt;/strong&gt;: A model architecture that understands the relationships between words.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;GPT predicts what comes next in a sentence by analyzing patterns in the data it was trained on.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  How Does an LLM Work?
&lt;/h2&gt;

&lt;p&gt;Let's walk through the three main phases of how a language model processes and generates language.&lt;/p&gt;




&lt;h3&gt;
  
  
  Phase 1: Understanding the Input
&lt;/h3&gt;

&lt;p&gt;This is where the model begins to process your prompt and understand what you're saying.&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%2Fdo0isgonnm72tgativq6.jpg" 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%2Fdo0isgonnm72tgativq6.jpg" alt=" " width="266" height="190"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Tokenization
&lt;/h4&gt;

&lt;p&gt;The first step is breaking down your sentence into smaller units called &lt;strong&gt;tokens&lt;/strong&gt;, which may be words or sub-words.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;"Today is a sunny day"&lt;/code&gt; → &lt;code&gt;[Today, is, a, sunny, day]&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;These tokens are then converted into numbers so the model can work with them mathematically. Each model has its own tokenization method and a fixed &lt;strong&gt;vocabulary size&lt;/strong&gt; (the total number of unique tokens it understands).&lt;/p&gt;

&lt;p&gt;Try out this code, or you could visit &lt;a href="https://tiktokenizer.vercel.app/" rel="noopener noreferrer"&gt;here&lt;/a&gt;; to see different tokens by different models.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import tiktoken
enc = tiktoken.encoding_for_model("gpt-4o")

text = "Hello, I am Shane" #Input Sequence

tokens = enc.encode(text)
print("Tokens: ", tokens ) #[13225, 11, 357, 939, 99388]

encodedTokens = [13225, 11, 357, 939, 99388]

decodedText = enc.decode(encodedTokens)
print("Decoded Text: ", decodedText) #Hello, I am Shane
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Vector Embeddings
&lt;/h3&gt;

&lt;p&gt;After tokenization, each token is mapped to a &lt;strong&gt;vector&lt;/strong&gt;, a string of numbers that represents its meaning.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Suppose, I mention the words &lt;code&gt;"Cat"&lt;/code&gt;, &lt;code&gt;"Dog"&lt;/code&gt;, &lt;code&gt;"Pedigree"&lt;/code&gt;, &lt;code&gt;"Dog Food"&lt;/code&gt;, &lt;code&gt;"Milk"&lt;/code&gt;, &lt;code&gt;"Cat Food"&lt;/code&gt;. Noticed you pictured these words in your mind while reading them.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Embeddings&lt;/strong&gt; give more context to a word, like showing a meaning rather than just a spelling.&lt;/p&gt;

&lt;p&gt;Try this code out, to see how vector embeddings would 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;from dotenv import load_dotenv
from openai import OpenAI

load_dotenv()

client = OpenAI()

text = "Today is a sunny day."

response = client.embeddings.create(
    model="text-embedding-3-small",
    input=text
)

print("Vector Embeddings: ",response)
print("Length", len(response.data[0].embedding)) #Dimensions (3D = 3 Dimensions)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Positional Encoding
&lt;/h3&gt;

&lt;p&gt;Since transformers look at the whole sentence at once (instead of word-by-word), they need to understand the position of each word. &lt;strong&gt;Positional encoding&lt;/strong&gt; give this structure, they tell the model the order in which words appear.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"He went to the bank to get some money."&lt;/em&gt;&lt;br&gt;&lt;br&gt;
&lt;em&gt;"They had a picnic by the river bank."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Without positional encoding, the model might confuse the two meanings of the word &lt;strong&gt;"bank."&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
But with it, the model understands that &lt;strong&gt;"bank"&lt;/strong&gt; means a financial institution in one case and a river's edge in the other, based on surrounding words and their positions.&lt;/p&gt;




&lt;h3&gt;
  
  
  Semantic Meaning
&lt;/h3&gt;

&lt;p&gt;Embeddings don't just turn words into numbers, they also capture the &lt;strong&gt;relationships&lt;/strong&gt; and &lt;strong&gt;meanings&lt;/strong&gt; behind those words.&lt;/p&gt;

&lt;p&gt;This is what allows the model to understand that some words are closely related, while others are not.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Examples:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The vectors for &lt;code&gt;king&lt;/code&gt; and &lt;code&gt;queen&lt;/code&gt; are close to each other, just like &lt;code&gt;man&lt;/code&gt; and &lt;code&gt;woman&lt;/code&gt;, because they share similar meanings.&lt;/li&gt;
&lt;li&gt;But the vectors for &lt;code&gt;pizza&lt;/code&gt; and &lt;code&gt;shoes&lt;/code&gt; are far apart, those words aren't related in meaning, so their embeddings reflect that distance.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Transformers: The Core of Modern AI
&lt;/h2&gt;

&lt;p&gt;Transformers are at the heart of all modern LLMs.&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%2Fpv2aaxl1fimzsn9hz5gi.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%2Fpv2aaxl1fimzsn9hz5gi.png" alt=" " width="501" height="688"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Originally introduced by Google in 2017 to improve Google Translate, transformers have since become the foundation of nearly every major AI models.&lt;/p&gt;

&lt;p&gt;Their research was published in the paper &lt;a href="https://proceedings.neurips.cc/paper_files/paper/2017/file/3f5ee243547dee91fbd053c1c4a845aa-Paper.pdf" rel="noopener noreferrer"&gt;“Attention Is All You Need”&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here's why they matter:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"He swung the bat at the ball.&lt;/em&gt;&lt;br&gt;
&lt;em&gt;"A bat flew out of the cave."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Even though both sentences contain the word &lt;strong&gt;“bat,”&lt;/strong&gt; you understood its meaning differently in each. That's &lt;strong&gt;context&lt;/strong&gt;, and transformers are built to capture it.&lt;/p&gt;

&lt;p&gt;Unlike older models that processed words one at a time, transformers look at the &lt;strong&gt;entire sentence all at once&lt;/strong&gt;. This allows the model to understand how words relate to each other, regardless of their position.&lt;/p&gt;

&lt;p&gt;That's how transformers help LLMs understand not just the words you use, but &lt;strong&gt;what you actually mean&lt;/strong&gt;.&lt;/p&gt;




&lt;h3&gt;
  
  
  Phase 2: Processing the Input
&lt;/h3&gt;

&lt;p&gt;This is where the model makes sense of the input and begins reasoning about 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%2Fut0ixiu915ur83vfhflr.jpg" 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%2Fut0ixiu915ur83vfhflr.jpg" alt=" " width="201" height="251"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  Encoder
&lt;/h3&gt;

&lt;p&gt;The encoder helps the model understand what you've written.&lt;/p&gt;

&lt;p&gt;It takes the input tokens and their embeddings (which include meaning and position) and transforms them into deeper representations that capture the sentence's full meaning and context. These internal representations are used by the model to figure out what you're trying to say.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"She unlocked the door with a key."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The encoder understands how each word is connected, that &lt;strong&gt;"she"&lt;/strong&gt; did something, &lt;strong&gt;"unlocked"&lt;/strong&gt; is the action, and &lt;strong&gt;"key"&lt;/strong&gt; was the tool. It doesn't just read words, it also understands the structure and relationships behind them.&lt;/p&gt;




&lt;h3&gt;
  
  
  Self-Attention
&lt;/h3&gt;

&lt;p&gt;Self-attention is a key feature of transformers. It allows the model to look at &lt;strong&gt;all the words in a sentence at once&lt;/strong&gt; and figure out how much attention each word should pay to the others.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"She poured coffee into the cup."&lt;/em&gt;&lt;br&gt;&lt;br&gt;
The model learns that the word &lt;strong&gt;"poured"&lt;/strong&gt; is closely related to both &lt;strong&gt;"coffee"&lt;/strong&gt; and &lt;strong&gt;"cup"&lt;/strong&gt;, because they all contribute to the action being described.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This helps the model understand which words matter most in context, rather than just reading one word at a time.&lt;/p&gt;




&lt;h3&gt;
  
  
  Multi-Head Attention
&lt;/h3&gt;

&lt;p&gt;Multi-head attention is like a &lt;strong&gt;team of specialists&lt;/strong&gt; working in parallel. Each "head" looks at the sentence from a different perspective:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;One might focus on grammar
&lt;/li&gt;
&lt;li&gt;Another might look at context
&lt;/li&gt;
&lt;li&gt;Another might track relationships between specific words&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each head captures something unique, and when combined, they give the model a richer and more complete understanding of the input.&lt;/p&gt;




&lt;h3&gt;
  
  
  Softmax
&lt;/h3&gt;

&lt;p&gt;Once the model processes the input, it generates a score for every possible next word.&lt;/p&gt;

&lt;p&gt;Softmax turns these raw scores into &lt;strong&gt;probabilities&lt;/strong&gt;, like a voting system. The higher the score, the more likely that word is to be chosen.&lt;/p&gt;

&lt;p&gt;The word with the highest probability (most "votes") is selected as the next word in the response.&lt;/p&gt;




&lt;h3&gt;
  
  
  Temperature
&lt;/h3&gt;

&lt;p&gt;This controls how &lt;strong&gt;creative or predictable&lt;/strong&gt; the model's responses are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Low temperature&lt;/strong&gt; → safe, reliable responses
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;High temperature&lt;/strong&gt; → more random, creative answers&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;It’s like adjusting a &lt;strong&gt;thermostat for imagination&lt;/strong&gt;.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  Phase 3: Generating a Response
&lt;/h3&gt;

&lt;p&gt;Now that the model understands your input, it's time to respond.&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%2F9zfmb26zitngf475n7xj.jpg" 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%2F9zfmb26zitngf475n7xj.jpg" alt=" " width="297" height="169"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  Decoder
&lt;/h3&gt;

&lt;p&gt;The decoder takes what the model has understood and starts generating a response, &lt;strong&gt;one word at a time&lt;/strong&gt;, like a builder laying bricks to form a sentence.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Input: &lt;em&gt;"The sky is..."&lt;/em&gt;&lt;br&gt;&lt;br&gt;
Output: &lt;em&gt;"blue."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Each word is chosen based on the context of the previous ones to keep the response natural and meaningful.&lt;/p&gt;




&lt;h3&gt;
  
  
  Inference
&lt;/h3&gt;

&lt;p&gt;Inference is the moment the model replies.&lt;/p&gt;

&lt;p&gt;No new learning happens here, the model isn't updating or training anymore. It's simply using what it already knows to generate a response based on your input.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Think of it like a chef following a recipe they've already mastered, just applying what they've learned.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  Knowledge Cutoff
&lt;/h3&gt;

&lt;p&gt;AI models aren't connected to the internet in real time. They can't look up new facts or news. They only know what they were trained on, up to a specific point in time, called the &lt;strong&gt;knowledge cutoff&lt;/strong&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;It's like a photo album frozen in time. Anything that happened after that date is missing, unless the model is retrained or updated.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;AI isn't magic. It’s just a very smart system trained on patterns from massive amounts of data.&lt;/p&gt;

&lt;p&gt;Once you understand a few key ideas, like &lt;strong&gt;tokens&lt;/strong&gt;, &lt;strong&gt;vectors&lt;/strong&gt;, &lt;strong&gt;attention&lt;/strong&gt;, and &lt;strong&gt;decoding&lt;/strong&gt;, you'll start to see how LLMs like ChatGPT actually work.&lt;/p&gt;

&lt;p&gt;Enjoyed this post?&lt;br&gt;
Found it helpful? Feel free to leave a comment, share it with your team, or follow along for more.&lt;/p&gt;

&lt;p&gt;🌐 &lt;a href="https://shanedsouza.com/" rel="noopener noreferrer"&gt;shanedsouza.com&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>genai</category>
      <category>agenticai</category>
    </item>
    <item>
      <title>Why 100 Lines of Code Can Be Better Than 2</title>
      <dc:creator>Shane Dsouza</dc:creator>
      <pubDate>Wed, 21 May 2025 04:22:13 +0000</pubDate>
      <link>https://dev.to/shanedsouza4/why-100-lines-of-code-can-be-better-than-2-5bj7</link>
      <guid>https://dev.to/shanedsouza4/why-100-lines-of-code-can-be-better-than-2-5bj7</guid>
      <description>&lt;p&gt;In programming, it's easy to assume that &lt;strong&gt;shorter code is better code&lt;/strong&gt;. It looks clean, compact, and clever, and we might believe it uses &lt;strong&gt;less memory&lt;/strong&gt;, and &lt;strong&gt;runs faster&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;But here's the catch:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Shorter doesn’t always mean smarter or more efficient.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Sometimes, a few extra lines of code can &lt;strong&gt;outperform&lt;/strong&gt; a clever one-liner, especially when it comes to reducing costly operations.&lt;/p&gt;

&lt;p&gt;Let’s look at a real-world analogy to make this clear.&lt;/p&gt;




&lt;h2&gt;
  
  
  📦 Product Boxes at a Factory
&lt;/h2&gt;

&lt;p&gt;9 identical product boxes are ready to ship. One of them has a manufacturing defect, it's heavier because it contains extra metal parts.&lt;br&gt;
Your task is to detect and remove it before quality inspection fails.&lt;/p&gt;


&lt;h3&gt;
  
  
  Approach 1: Straightforward
&lt;/h3&gt;

&lt;p&gt;You weigh each box one by one.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int boxes[9] = {1, 1, 1, 1, 1, 1, 1, 4, 1}; // 4 is the heavier box

for (int i = 0; i &amp;lt; 9; i++) {
    if (boxes[i] &amp;gt; 1) {
        return boxes[i];
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Number of weigh-ins&lt;/strong&gt;: Up to 9&lt;br&gt;
&lt;strong&gt;Efficiency&lt;/strong&gt;: Low — especially if the heavy box is at the end.&lt;/p&gt;


&lt;h3&gt;
  
  
  Approach 2: Smart Approach
&lt;/h3&gt;

&lt;p&gt;Split the 9 boxes into 3 groups of 3 and compare their total weights.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int boxes[9] = {1, 1, 2, 1, 1, 1, 1, 1, 1}; // 2 is the heavier box

int group1 = boxes[0] + boxes[1] + boxes[2];
int group2 = boxes[3] + boxes[4] + boxes[5];
int group3 = boxes[6] + boxes[7] + boxes[8];

if (group1 == group2) {

    // Faulty box is in group3
    if (boxes[6] &amp;gt; boxes[7]) 
          return boxes[6];
    else if (boxes[7] &amp;gt; boxes[6]) 
          return boxes[7];
    else 
          return boxes[8];

} else if (group1 &amp;gt; group2) {

    // Faulty box is in group1
    if (boxes[0] &amp;gt; boxes[1]) 
          return boxes[0];
    else if (boxes[1] &amp;gt; boxes[0]) 
          return boxes[1];
    else 
          return boxes[2];

} else {

    // Faulty box is in group2
    if (boxes[3] &amp;gt; boxes[4]) 
          return boxes[3];
    else if (boxes[4] &amp;gt; boxes[3]) 
          return boxes[4];
    else 
          return boxes[5];
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Number of weigh-ins&lt;/strong&gt;: Just 2 or 3&lt;br&gt;
&lt;strong&gt;Efficiency&lt;/strong&gt;: Much better, faster fault detection.&lt;/p&gt;




&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;While concise code can be elegant, it's not always the most effective solution. As we've seen, a longer approach can significantly improve performance and clarity.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Short code isn’t automatically good code.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;What's more important is whether your solution is &lt;strong&gt;readable, maintainable,&lt;/strong&gt; and &lt;strong&gt;efficient&lt;/strong&gt;.&lt;/p&gt;




&lt;p&gt;Enjoyed this post?&lt;br&gt;
Found it helpful? Feel free to leave a comment, share it with your team, or follow along for more.&lt;/p&gt;

&lt;p&gt;🌐 &lt;a href="https://shanedsouza.com/" rel="noopener noreferrer"&gt;shanedsouza.com&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>beginners</category>
      <category>cleancode</category>
    </item>
    <item>
      <title>Commit To Code: Working with Git Pull Requests &amp; Conflict Resolution</title>
      <dc:creator>Shane Dsouza</dc:creator>
      <pubDate>Mon, 21 Apr 2025 04:28:01 +0000</pubDate>
      <link>https://dev.to/shanedsouza4/commit-to-code-working-with-pull-requests-conflict-resolution-4a9j</link>
      <guid>https://dev.to/shanedsouza4/commit-to-code-working-with-pull-requests-conflict-resolution-4a9j</guid>
      <description>&lt;p&gt;📚 &lt;strong&gt;Git &amp;amp; GitHub Series&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
➡️ &lt;em&gt;You're reading Part 5&lt;/em&gt;&lt;br&gt;&lt;br&gt;
⬅️ &lt;a href="https://dev.to/shanedsouza4/commit-to-code-branching-merging-squashing-rebasing-3b64"&gt;Part 4: Branching, Merging, Squashing &amp;amp; Rebasing&lt;/a&gt;&lt;/p&gt;


&lt;h1&gt;
  
  
  Working with Pull Requests &amp;amp; Conflict Resolution
&lt;/h1&gt;

&lt;p&gt;Pull Requests (PRs) are the heart of collaborative coding. Whether you're working solo or on a team, understanding how to open, review, and resolve conflicts in PRs is a crucial skill.&lt;/p&gt;


&lt;h2&gt;
  
  
  What is a Pull Request?
&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;Pull Request (PR)&lt;/strong&gt; is a request to merge code from one branch into another (usually into &lt;code&gt;main&lt;/code&gt;). PRs are managed on platforms like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;GitHub&lt;/li&gt;
&lt;li&gt;GitLab&lt;/li&gt;
&lt;li&gt;Bitbucket&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Think of a PR as saying:&lt;br&gt;&lt;br&gt;
“Hey team, I’ve finished some work. Can you review and approve it before we add it to the main codebase?”&lt;/p&gt;
&lt;/blockquote&gt;


&lt;h2&gt;
  
  
  Creating a Pull Request on GitHub
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Step 1: Create a Feature Branch and Push Your Changes
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git checkout -b feat/user-login
git add .
git commit -m "Add user login feature"
git push --set-upstream origin feat/user-login
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;We then check the commit history:&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%2Frmlhwijf4boxcxio9c02.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%2Frmlhwijf4boxcxio9c02.png" alt="gitlog" width="800" height="412"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 2:  Visit GitHub
&lt;/h3&gt;

&lt;p&gt;GitHub will show:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“This branch is X commits ahead of main. Compare &amp;amp; pull request.”&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%2Fhp2yh3t7k5v0a9km7kwa.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%2Fhp2yh3t7k5v0a9km7kwa.png" alt="Image description" width="800" height="601"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click &lt;strong&gt;Compare &amp;amp; pull request&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Fill in:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;strong&gt;clear title&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;description&lt;/strong&gt; of what the PR does (Markdown and checklists work great!)&lt;/li&gt;
&lt;/ul&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%2Fcdvd5yhlkbuca3obs2hm.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%2Fcdvd5yhlkbuca3obs2hm.png" alt="Image description" width="800" height="406"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click &lt;strong&gt;Create Pull Request&lt;/strong&gt;&lt;/p&gt;



&lt;p&gt;&lt;strong&gt;What Happens After Creating a PR?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Your teammates &lt;strong&gt;review&lt;/strong&gt; your code&lt;/li&gt;
&lt;li&gt;They may &lt;em&gt;**comment, request changes&lt;/em&gt;&lt;em&gt;, or **approve&lt;/em&gt;*&lt;/li&gt;
&lt;li&gt;Once approved, it gets &lt;strong&gt;merged into&lt;/strong&gt; &lt;code&gt;main&lt;/code&gt; (usually with a regular or squash merge)&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;
  
  
  Conflict Resolution in Git
&lt;/h2&gt;

&lt;p&gt;Conflicts happen when two branches change the &lt;strong&gt;same part of a file differently&lt;/strong&gt;. Git can’t decide which version to keep, so it flags a merge conflict.&lt;/p&gt;


&lt;h3&gt;
  
  
  Resolving Conflicts Safely in a PR
&lt;/h3&gt;

&lt;p&gt;Sometimes your PR shows conflicts with &lt;code&gt;main&lt;/code&gt; &lt;strong&gt;after it's already created&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Strategy: Merge &lt;code&gt;main&lt;/code&gt; into your PR branch&lt;/strong&gt;&lt;br&gt;
This keeps the PR alive and lets you fix conflicts cleanly.&lt;/p&gt;



&lt;p&gt;&lt;strong&gt;Option A: Fix Inside Your PR Branch&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;git checkout feat/user-auth
git pull origin main
# Resolve conflicts
git add .
git commit -m "Resolve conflicts with main"
git push

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Option B: Fix Using a Temporary Helper Branch&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is cleaner and more review-friendly.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Step 1: Switch to your PR branch
git checkout feat/user-auth

# Step 2: Create a helper branch
git checkout -b feat/user-auth-merge-fix

# Step 3: Merge main into it
git merge main
# OR rebase if preferred:
# git rebase main

# Step 4: Resolve conflicts
# Step 5: Commit the resolution
git add .
git commit -m "Resolved conflicts with main"

# Step 6: Push the helper branch
git push origin feat/user-auth-merge-fix
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, create a &lt;strong&gt;new PR&lt;/strong&gt; from &lt;code&gt;feat/user-auth-merge-fix → feat/user-auth&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Once merged, your original PR is conflict-free and ready to go.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why This Strategy Works&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Keeps your &lt;strong&gt;PR branch clean&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Lets you resolve conflicts &lt;strong&gt;independently&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Makes the fix &lt;strong&gt;reviewable as a separate PR&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Simulating a Merge Conflict
&lt;/h3&gt;

&lt;h4&gt;
  
  
  1. From &lt;code&gt;main&lt;/code&gt;, create a shared file:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;echo "Hello World" &amp;gt; hello.txt
git add hello.txt
git commit -m "Initial hello.txt"
git push
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Foxrfqji6y13d74e5ujez.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%2Foxrfqji6y13d74e5ujez.png" alt="Image description" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  2. Branch A (Developer A):
&lt;/h4&gt;

&lt;p&gt;git checkout -b feat/greeting&lt;br&gt;
echo "Hello from branch A" &amp;gt; hello.txt&lt;br&gt;
git commit -am "Branch A greeting"&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%2Focnwxtixsmvlkf6ikplb.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%2Focnwxtixsmvlkf6ikplb.png" alt="Image description" width="800" height="337"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  3. Branch B (Developer B):
&lt;/h4&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git checkout main
git checkout -b feat/salutation
echo "Hi from branch B" &amp;gt; hello.txt
git commit -am "Branch B greeting"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fb9z7zj0pkdo03mway6eb.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%2Fb9z7zj0pkdo03mway6eb.png" alt="Image description" width="800" height="392"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  4. Now merge both into main. The second merge will trigger:
&lt;/h4&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CONFLICT (content): Merge conflict in hello.txt
Automatic merge failed; fix conflicts and then commit the result.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fm2w1nobc5fc14hmsav63.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%2Fm2w1nobc5fc14hmsav63.png" alt="Image description" width="800" height="416"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Fixing the Merge Conflict
&lt;/h3&gt;
&lt;h4&gt;
  
  
  1. Open the conflicted file. You'll see:
&lt;/h4&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%2Fjg1vu40a1ojj3a64z53a.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%2Fjg1vu40a1ojj3a64z53a.png" alt="Image description" width="800" height="219"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  2. Edit the file to combine or choose changes:
&lt;/h4&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%2Fplevq0jmv4r8kb34xra9.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%2Fplevq0jmv4r8kb34xra9.png" alt="Image description" width="800" height="320"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  3. Mark it as resolved:
&lt;/h4&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%2F72wvz5edebruh1b2uh0w.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%2F72wvz5edebruh1b2uh0w.png" alt="Image description" width="800" height="196"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git add hello.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  4. Commit the resolved merge:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git commit -m "Resolve merge conflict between feat/greeting and feat/salutation"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2F7ycgcnv99bcz6ix9gbrn.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%2F7ycgcnv99bcz6ix9gbrn.png" alt="Image description" width="800" height="115"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Best Practices for Conflict Resolution
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Pull often from main to stay up-to-date:
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Keep PRs small and focused&lt;/li&gt;
&lt;li&gt;Use clear commit messages when fixing conflicts&lt;/li&gt;
&lt;li&gt;Avoid editing the same file as others if possible&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Wrapping Up
&lt;/h2&gt;

&lt;p&gt;In this article, you learned:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What a Pull Request is and how to open one&lt;/li&gt;
&lt;li&gt;How to handle team feedback and approvals&lt;/li&gt;
&lt;li&gt;What merge conflicts are and how to resolve them&lt;/li&gt;
&lt;li&gt;How to handle conflicts cleanly with helper branches&lt;/li&gt;
&lt;li&gt;Best practices to reduce and manage merge conflicts&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Using PRs effectively will help you collaborate confidently, maintain a clean main branch, and avoid headaches when merging code.&lt;/p&gt;

&lt;h3&gt;
  
  
  📚 More from the Series
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://dev.to/shanedsouza4/commit-to-code-why-git-github-matter-4llf"&gt;Part 1: Why Git &amp;amp; GitHub Matter&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/shanedsouza4/commit-to-code-setting-up-git-and-github-4o2b"&gt;Part 2: Setting Up Git and GitHub&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/shanedsouza4/commit-to-code-creating-commits-exploring-the-git-folder-pno"&gt;Part 3: Creating Commits &amp;amp; Exploring the .git Folder&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/shanedsouza4/commit-to-code-branching-merging-squashing-rebasing-3b64"&gt;Part 4: Branching, Merging, Squashing &amp;amp; Rebasing&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;✅ Part 5: &lt;em&gt;You're here!&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;Enjoyed this post?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Found this helpful? Drop a comment, share it with your team, or follow along for the next deep dive.&lt;/p&gt;

&lt;p&gt;🌐 &lt;a href="https://shanedsouza.com/" rel="noopener noreferrer"&gt;shanedsouza.com&lt;/a&gt;&lt;/p&gt;

</description>
      <category>git</category>
      <category>github</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>Commit to Code: Branching, Merging, Squashing &amp; Rebasing with Git &amp; GitHub</title>
      <dc:creator>Shane Dsouza</dc:creator>
      <pubDate>Mon, 21 Apr 2025 03:16:39 +0000</pubDate>
      <link>https://dev.to/shanedsouza4/commit-to-code-branching-merging-squashing-rebasing-3b64</link>
      <guid>https://dev.to/shanedsouza4/commit-to-code-branching-merging-squashing-rebasing-3b64</guid>
      <description>&lt;p&gt;📚 &lt;strong&gt;Git &amp;amp; GitHub Series&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
➡️ &lt;em&gt;You're reading Part 4&lt;/em&gt;&lt;br&gt;&lt;br&gt;
⬅️ &lt;a href="https://dev.to/shanedsouza4/commit-to-code-creating-commits-exploring-the-git-folder-pno"&gt;Part 3: Creating Commits &amp;amp; Exploring the .git Folder&lt;/a&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  Understanding Branching with an Analogy
&lt;/h2&gt;

&lt;p&gt;Think of a &lt;strong&gt;branch&lt;/strong&gt; in Git as a &lt;strong&gt;railway track&lt;/strong&gt;.&lt;br&gt;&lt;br&gt;
Each &lt;strong&gt;commit&lt;/strong&gt; is like a &lt;strong&gt;rail car&lt;/strong&gt; placed on that track, and the &lt;strong&gt;branch name&lt;/strong&gt; (e.g., &lt;code&gt;main&lt;/code&gt;) is the track's label.&lt;/p&gt;

&lt;p&gt;Now let’s imagine two developers, Developer A and Developer B, working on their respective features.&lt;/p&gt;


&lt;h3&gt;
  
  
  Why Not Work on the Same Branch?
&lt;/h3&gt;

&lt;p&gt;If both developers work directly on the same branch (&lt;code&gt;main&lt;/code&gt;), over time the commit history gets polluted.&lt;/p&gt;

&lt;p&gt;Now imagine if we need to &lt;strong&gt;revert Developer A’s changes&lt;/strong&gt;, doing so would also affect Developer B’s work.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;This is why we avoid working directly on &lt;code&gt;main&lt;/code&gt; and instead &lt;strong&gt;create branches&lt;/strong&gt;.&lt;/p&gt;
&lt;/blockquote&gt;


&lt;h3&gt;
  
  
  How Branching Helps
&lt;/h3&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%2Fyhdbbo5r9gulme9ehx91.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%2Fyhdbbo5r9gulme9ehx91.png" alt="Branching Overview" width="800" height="349"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At the beginning, the HEAD (which points to the latest commit) is on the last commit of the &lt;code&gt;main&lt;/code&gt; branch.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Developer A needs to work on a new feature.&lt;/li&gt;
&lt;li&gt;They create a new branch from &lt;code&gt;main&lt;/code&gt; using:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git checkout -b feat/a
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Developer A commits code into &lt;code&gt;feat/a&lt;/code&gt;, creating 3 commits.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Meanwhile, other contributors may add commits to the &lt;code&gt;main&lt;/code&gt; branch, moving its HEAD forward.&lt;/p&gt;

&lt;p&gt;When Developer A completes their work:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;feat/a&lt;/code&gt; branch is merged back into &lt;code&gt;main&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The merge can happen in one of two ways:&lt;/li&gt;
&lt;li&gt;As individual commits&lt;/li&gt;
&lt;li&gt;As a single commit using squash:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git merge --squash feat/a
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Real-World Git Rules (In Companies)
&lt;/h3&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%2Fbumegdci32yn0ydzpxcn.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%2Fbumegdci32yn0ydzpxcn.png" alt="Branching overview in companies" width="800" height="281"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Different organizations follow different Git workflows, but a common approach includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;main&lt;/code&gt; branch is treated as the &lt;strong&gt;Single Source of Truth&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Developers never push directly to &lt;code&gt;main&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Instead, they follow a similar process to this:&lt;/li&gt;
&lt;li&gt;Create a feature branch (e.g., &lt;code&gt;feat/login&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Push it to the remote repository.&lt;/li&gt;
&lt;li&gt;Open a &lt;strong&gt;Pull Request&lt;/strong&gt; (PR) to merge into &lt;code&gt;main&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The PR is &lt;strong&gt;reviewed&lt;/strong&gt;, &lt;strong&gt;discussed&lt;/strong&gt;, and &lt;strong&gt;approved&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;After approval, it gets merged into &lt;code&gt;main&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;This keeps the &lt;code&gt;main&lt;/code&gt; branch clean, stable, and production-ready.&lt;/p&gt;
&lt;/blockquote&gt;


&lt;h3&gt;
  
  
  Branch Naming Conventions in Companies
&lt;/h3&gt;

&lt;p&gt;To maintain clarity and consistency across teams, branches are often named following specific patterns:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git branch "feat/whatsapp-integration" #New feature
git branch "bug/login-not-working" #Fixing a bug 
git branch "wip/wontBeFinishedSoon" #Work in progress
git branch "junk/experimenting" #Temporary or experimental work
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  💡 Best Practices for Branch Naming:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Always use lowercase letters and hyphens &lt;code&gt;-&lt;/code&gt; to separate words.&lt;/li&gt;
&lt;li&gt;Start the branch name with a category prefix (&lt;code&gt;feat/&lt;/code&gt;, &lt;code&gt;bug/&lt;/code&gt;, &lt;code&gt;wip/&lt;/code&gt;, &lt;code&gt;story/&lt;/code&gt;, &lt;code&gt;junk/&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Keep branch names short but descriptive.&lt;/li&gt;
&lt;li&gt;Avoid using spaces or special characters other than &lt;code&gt;-&lt;/code&gt; and &lt;code&gt;/&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;A consistent naming convention makes it easier to automate workflows, review pull requests, and manage releases.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Let's Perform Branching &amp;amp; Merging in Git
&lt;/h2&gt;

&lt;p&gt;Follow along with this hands-on example to understand branching, committing, and merging.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Check Which Branch You’re On
&lt;/h3&gt;

&lt;p&gt;To see your current branch:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;You’ll likely see &lt;code&gt;main&lt;/code&gt; (or &lt;code&gt;master&lt;/code&gt;).&lt;br&gt;
If you’re not on main, switch to it:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2: Create a New File and Commit
&lt;/h3&gt;

&lt;p&gt;Create a file named &lt;code&gt;feat-a.html&lt;/code&gt; and add some text inside the &lt;code&gt;&amp;lt;body&amp;gt;&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Then stage and commit the file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git add feat-a.html
git commit -m "Working on feat/a"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 3: Create a Branch from &lt;code&gt;main&lt;/code&gt; and Switch to It
&lt;/h3&gt;

&lt;p&gt;Let’s say you want to start working on Feature B:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git checkout -b feat/b
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Creates a new branch &lt;code&gt;feat/b&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Checks out into it (i.e., switches to it)&lt;/li&gt;
&lt;li&gt;Sets &lt;code&gt;HEAD&lt;/code&gt; at the last commit from &lt;code&gt;main&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&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%2Fwvfcmw5z1fuusg96gzsc.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%2Fwvfcmw5z1fuusg96gzsc.png" alt="Image description" width="741" height="528"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 4: Make Changes and Commit in the New Branch
&lt;/h4&gt;

&lt;p&gt;Create a file called &lt;code&gt;feat-b.html&lt;/code&gt;, add some content in it, and make two commits:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git add feat-b.html
git commit -m "Added feature b file"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make another small change, then:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git commit -am "Updated feature b file"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Step 5: View the Commit History
&lt;/h4&gt;

&lt;p&gt;You can view commit history in two ways:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Or a simplified version:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git log --oneline
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Ffy0pbcv1mxalx959784d.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%2Ffy0pbcv1mxalx959784d.png" alt="Image description" width="800" height="220"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 6: Merge &lt;code&gt;feat/b&lt;/code&gt; into &lt;code&gt;main&lt;/code&gt;
&lt;/h4&gt;

&lt;p&gt;Now that your work is done in &lt;code&gt;feat/b&lt;/code&gt;, let’s merge it back to &lt;code&gt;main&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;git checkout main
git merge feat/b
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fw40ambali7zf77f6ney7.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%2Fw40ambali7zf77f6ney7.png" alt="Image description" width="800" height="445"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Your changes from &lt;code&gt;feat/b&lt;/code&gt; are now part of the &lt;code&gt;main&lt;/code&gt; branch.&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 7: Create a New Branch and Switch in One Command
&lt;/h4&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%2Fuexv4gtqo4vxf1v93tn7.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%2Fuexv4gtqo4vxf1v93tn7.png" alt="Create branch in one command" width="800" height="243"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is a shortcut to create and move into a branch:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git checkout -b feat/c
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make some changes in &lt;code&gt;feat/c&lt;/code&gt;, then:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git add feat-c.html
git commit -m "Added feature c"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then merge into &lt;code&gt;main&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;git checkout main
git merge feat/c
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Step 8: View Your Updated Commit History
&lt;/h4&gt;

&lt;p&gt;After the merges:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git log --oneline
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2F3vdf5o9idqr6ks9wd7ok.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%2F3vdf5o9idqr6ks9wd7ok.png" alt="Commit History" width="800" height="329"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You’ll see the new commits from &lt;code&gt;feat/b&lt;/code&gt; and &lt;code&gt;feat/c&lt;/code&gt; as part of the main branch history.&lt;/p&gt;




&lt;h2&gt;
  
  
  Delete Merged Branches (Recommended)
&lt;/h2&gt;

&lt;p&gt;To keep your branch list clean, delete branches that have already been merged:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git branch -d feat/b
git branch -d feat/c
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This won’t delete any history, your changes are already part of the &lt;code&gt;main&lt;/code&gt; branch.&lt;/p&gt;




&lt;h2&gt;
  
  
  What Is a Squash Merge?
&lt;/h2&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%2F2bea4zeiw6ok29iei9re.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%2F2bea4zeiw6ok29iei9re.png" alt="Image description" width="800" height="290"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Squashing&lt;/strong&gt; is a hybrid merging approach where &lt;strong&gt;multiple commits are combined into a single commit&lt;/strong&gt; at the time of merging a branch.&lt;/p&gt;

&lt;p&gt;When you merge a feature branch into &lt;code&gt;main&lt;/code&gt; using &lt;strong&gt;squash&lt;/strong&gt;, Git adds all changes but keeps the &lt;code&gt;main&lt;/code&gt; branch history clean.&lt;/p&gt;




&lt;h3&gt;
  
  
  Benefits of Squash Merging:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Clean history&lt;/strong&gt; – Only one commit added to &lt;code&gt;main&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Removes noise&lt;/strong&gt; – No clutter from WIP commits or small fixes&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Disadvantages of Squash Merging:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;History is lost&lt;/strong&gt; – You lose visibility into the original commit timeline&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Harder to debug&lt;/strong&gt; – Can be challenging if something goes wrong and you need fine-grained history&lt;/li&gt;
&lt;/ol&gt;




&lt;h3&gt;
  
  
  Try It Yourself: Squash Example
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Create a new branch:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git checkout -b feat/d
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Create a file feat-d.html, and make 4 commits with different content.&lt;/li&gt;
&lt;li&gt;View the commit log:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git log --oneline
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Frqrdhw3qk0ifmlaa2vcb.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%2Frqrdhw3qk0ifmlaa2vcb.png" alt="Image description" width="800" height="527"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You’ll see 4 separate commits in &lt;code&gt;feat/d&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Now Squash the Branch into Main
&lt;/h3&gt;

&lt;p&gt;Switch to the &lt;code&gt;main&lt;/code&gt; branch:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Perform a squash merge:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git merge --squash feat/d
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Git will stage all changes from &lt;code&gt;feat/d&lt;/code&gt;. Now create a single squashed commit:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git commit -m "Squashed: Feature D implementation"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check the updated commit log:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git log --oneline
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2F34qovd5qggrleov36vl3.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%2F34qovd5qggrleov36vl3.png" alt="Image description" width="800" height="469"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You’ll see just one new commit on &lt;code&gt;main&lt;/code&gt;. &lt;br&gt;
The 4 commits from &lt;code&gt;feat/d&lt;/code&gt; are not shown separately. &lt;/p&gt;


&lt;h3&gt;
  
  
  Visual Breakdown
&lt;/h3&gt;

&lt;p&gt;Let's break down how a branch is created and how merging works with and without squash.&lt;/p&gt;



&lt;p&gt;&lt;strong&gt;Creating the Branch&lt;/strong&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%2Fdm9pw6bxpusw7s5tlnjs.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%2Fdm9pw6bxpusw7s5tlnjs.png" alt="Creating the branch" width="800" height="317"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;p&gt;&lt;strong&gt;Regular Merge&lt;/strong&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%2F86xm4o9ust1ppmihe3gk.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%2F86xm4o9ust1ppmihe3gk.png" alt="Regular Merge" width="800" height="317"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;p&gt;&lt;strong&gt;Squash Merge&lt;/strong&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%2Ftvkz2v2i6hhufi3mu929.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%2Ftvkz2v2i6hhufi3mu929.png" alt="Squash Merge" width="800" height="290"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;h3&gt;
  
  
  Real-World Scenario: GitHub Flow with Squash
&lt;/h3&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%2Fsvuhc9ure5xrpkbc7r3g.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%2Fsvuhc9ure5xrpkbc7r3g.png" alt="GitHub Flow with Squash" width="800" height="470"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s say your branch is 3 commits ahead of &lt;code&gt;main&lt;/code&gt;.&lt;/p&gt;


&lt;h3&gt;
  
  
  1. Create a Feature Branch
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git checkout -b feat/z
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  2. Make 3 Commits and Push
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git push --set-upstream origin feat/z
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Once pushed, GitHub will show:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"3 commits ahead of main"&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%2Fxktegu0xqyijrjvh049q.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%2Fxktegu0xqyijrjvh049q.png" alt="Ahead of main" width="800" height="525"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  3. Open a Pull Request
&lt;/h3&gt;

&lt;p&gt;Suppose your organization has locked the &lt;code&gt;main&lt;/code&gt; branch — you can't push directly.&lt;/p&gt;

&lt;p&gt;So, you'll create a Pull Request by clicking &lt;strong&gt;"Compare &amp;amp; pull request"&lt;/strong&gt; on 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%2Fjvy0txl14271rahbdjcm.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%2Fjvy0txl14271rahbdjcm.png" alt="Compare and PR" width="800" height="316"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  4. Choose Squash &amp;amp; Merge
&lt;/h3&gt;

&lt;p&gt;To merge cleanly into &lt;code&gt;main&lt;/code&gt;, select &lt;strong&gt;"Squash and Merge"&lt;/strong&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%2Fypebfg3mvet7zjn6r8q4.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%2Fypebfg3mvet7zjn6r8q4.png" alt="Squash Merge" width="800" height="132"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This will:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Combine all 3 commits into one&lt;/li&gt;
&lt;li&gt;Add a clean commit message to &lt;code&gt;main&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Automatically link the PR (e.g. &lt;code&gt;#3&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Leave the feature branch (&lt;code&gt;feat/z&lt;/code&gt;) visible until deleted&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;This keeps the &lt;code&gt;main&lt;/code&gt; timeline clean while retaining traceability via the PR number.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;
  
  
  5. Pull the Latest Changes to Your Local &lt;code&gt;main&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;After merging the PR, update your local repo:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git checkout main 
git pull origin main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fh81lehai760tnoh9q2ol.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%2Fh81lehai760tnoh9q2ol.png" alt="Pull latest" width="800" height="402"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By following this squash-based GitHub flow, your history stays clean, yet your collaboration remains fully traceable.&lt;/p&gt;




&lt;h2&gt;
  
  
  Git Rebase
&lt;/h2&gt;

&lt;p&gt;Rebase is powerful, clean, and dangerous if misused.&lt;br&gt;
It rewrites commit history by placing your branch commits on top of another branch (usually &lt;code&gt;main&lt;/code&gt;).&lt;/p&gt;
&lt;h2&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%2Fb7gqxikq0n5xh1n1anex.png" alt="Image description" width="800" height="250"&gt;
&lt;/h2&gt;
&lt;h3&gt;
  
  
  When to Rebase?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;You're working on a feature branch&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;main&lt;/code&gt; has moved ahead&lt;/li&gt;
&lt;li&gt;You want your branch to reflect the latest changes before merging&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Common Mistake
&lt;/h3&gt;

&lt;p&gt;If you’re on &lt;code&gt;feat/b&lt;/code&gt;, &lt;strong&gt;avoid this&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;git merge main  # This works but pollutes the history
&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 plaintext"&gt;&lt;code&gt;git merge --squash main  # Uncommon usage, may not behave as expected
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Correct Way: Rebase
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git checkout feat/b
git rebase main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This replays your commits on top of the latest from &lt;code&gt;main&lt;/code&gt;, keeping your history linear and clean.&lt;/p&gt;

&lt;h3&gt;
  
  
  Best Practice for Merging Into Main
&lt;/h3&gt;

&lt;p&gt;To keep the &lt;code&gt;main&lt;/code&gt; branch clean and organized:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git checkout main
git merge --squash feat/b
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This brings in all the changes from your feature branch as &lt;strong&gt;one commit&lt;/strong&gt; and avoids clutter in the commit log.&lt;/p&gt;




&lt;h2&gt;
  
  
  Wrapping Up
&lt;/h2&gt;

&lt;p&gt;In this article, you learned:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Why branching is essential for clean, collaborative development&lt;/li&gt;
&lt;li&gt;How to create, switch, and merge branches safely&lt;/li&gt;
&lt;li&gt;The difference between regular merges and squash merges&lt;/li&gt;
&lt;li&gt;How teams manage contributions using Pull Requests&lt;/li&gt;
&lt;li&gt;The role of squash merges — both in GitHub and locally&lt;/li&gt;
&lt;li&gt;How &lt;code&gt;git rebase&lt;/code&gt; can help you keep a linear commit history&lt;/li&gt;
&lt;li&gt;Real-world branch naming conventions used in professional workflows&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By applying these concepts, you’ll keep your repository organized, your main branch production-ready, and your team collaboration smooth.&lt;/p&gt;




&lt;h3&gt;
  
  
  📚 More from the Series
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://dev.to/shanedsouza4/commit-to-code-why-git-github-matter-4llf"&gt;Part 1: Why Git &amp;amp; GitHub Matter&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/shanedsouza4/commit-to-code-setting-up-git-and-github-4o2b"&gt;Part 2: Setting Up Git and GitHub&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/shanedsouza4/commit-to-code-creating-commits-exploring-the-git-folder-pno"&gt;Part 3: Creating Commits &amp;amp; Exploring the .git Folder&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;✅ Part 4: &lt;em&gt;You're here!&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/shanedsouza4/commit-to-code-working-with-pull-requests-conflict-resolution-4a9j"&gt;Part 5: Working with Pull Requests &amp;amp; Conflict Resolution&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;Enjoyed this post?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Found this helpful? Drop a comment, share it with your team, or follow along for the next deep dive.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://shanedsouza.com/" rel="noopener noreferrer"&gt;shanedsouza.com&lt;/a&gt;&lt;/p&gt;

</description>
      <category>git</category>
      <category>github</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>Commit to Code: Creating Git Commits &amp; Exploring the .git Folder</title>
      <dc:creator>Shane Dsouza</dc:creator>
      <pubDate>Sun, 20 Apr 2025 03:36:45 +0000</pubDate>
      <link>https://dev.to/shanedsouza4/commit-to-code-creating-commits-exploring-the-git-folder-pno</link>
      <guid>https://dev.to/shanedsouza4/commit-to-code-creating-commits-exploring-the-git-folder-pno</guid>
      <description>&lt;p&gt;📚 &lt;strong&gt;Git &amp;amp; GitHub Series&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
➡️ &lt;em&gt;You're reading Part 3&lt;/em&gt;&lt;br&gt;&lt;br&gt;
⬅️ &lt;a href="https://dev.to/shanedsouza4/commit-to-code-setting-up-git-and-github-4o2b"&gt;Part 2: Setting Up Git and GitHub&lt;/a&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  Getting Started with Git Tracking
&lt;/h2&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%2Ffa1tw0d4xyqarnqljmxt.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%2Ffa1tw0d4xyqarnqljmxt.png" alt="Creating a Git-tracked folder" width="800" height="253"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Create a folder named &lt;code&gt;Git-Learning&lt;/code&gt; and add a file (e.g. &lt;code&gt;hello.txt&lt;/code&gt;) with some text.&lt;/p&gt;

&lt;p&gt;At this point, Git is &lt;strong&gt;not tracking&lt;/strong&gt; this folder or file. Git doesn’t track every folder on your machine by default — you need to initialize it.&lt;/p&gt;


&lt;h2&gt;
  
  
  Initializing Git
&lt;/h2&gt;

&lt;p&gt;To allow Git to start tracking this project, run:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&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%2F9pvvrr3ut4wbm66hneb5.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%2F9pvvrr3ut4wbm66hneb5.png" alt="Git init command output" width="800" height="261"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Git now tracks this folder.&lt;br&gt;&lt;br&gt;
You'll see a &lt;strong&gt;U&lt;/strong&gt; next to the file name, meaning &lt;strong&gt;Untracked&lt;/strong&gt;.&lt;/p&gt;


&lt;h2&gt;
  
  
  How Does Git Track?
&lt;/h2&gt;

&lt;p&gt;Once &lt;code&gt;git init&lt;/code&gt; is run, Git creates a hidden &lt;code&gt;.git&lt;/code&gt; folder — the &lt;strong&gt;brain of Git&lt;/strong&gt;. It contains everything about your project's history.&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%2Fr8oackzhycebnbetcrzw.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%2Fr8oackzhycebnbetcrzw.png" alt="The hidden .git folder" width="800" height="159"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  Staging Files
&lt;/h2&gt;

&lt;p&gt;When a file needs to be tracked it is moved over to the Staging Area.&lt;/p&gt;

&lt;p&gt;To track a specific file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git add hello.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To track all files:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git add .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now files will show &lt;strong&gt;A&lt;/strong&gt;, meaning &lt;strong&gt;Added&lt;/strong&gt; to staging.&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%2F2ibeq9qyatsz9v5yvcje.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%2F2ibeq9qyatsz9v5yvcje.png" alt="Staging with git add" width="800" height="308"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  What’s Inside the .git Folder?
&lt;/h2&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%2Fqla0x1uft3n3kwqa3pa4.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%2Fqla0x1uft3n3kwqa3pa4.png" alt="Exploring .git contents" width="800" height="502"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Some key components:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;index&lt;/code&gt; — tracks files in the staging area.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;objects&lt;/code&gt; — where Git stores commit data.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;HEAD&lt;/code&gt; — points to the current branch or commit.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's try reading the index 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%2Fya2mo91x5mzg0kshe2mg.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%2Fya2mo91x5mzg0kshe2mg.png" alt="Reading the index file" width="800" height="68"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Use this to view what's staged or untracked:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&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%2Fh3alv87rpblisuf2hxrz.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%2Fh3alv87rpblisuf2hxrz.png" alt="Output of git status" width="800" height="283"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Git reads from the index file to show you what's staged, modified, or untracked.&lt;/p&gt;




&lt;h2&gt;
  
  
  Creating a Commit
&lt;/h2&gt;

&lt;p&gt;A commit is like a snapshot of your code at a specific moment:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git commit -m "Initial commit"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fry2wa21l0nfrfeobhhka.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%2Fry2wa21l0nfrfeobhhka.png" alt="Commit created" width="800" height="153"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Each commit generates a unique hash ID and stores:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Author name and email&lt;/li&gt;
&lt;li&gt;Date and time&lt;/li&gt;
&lt;li&gt;Commit message
Reference to the previous commit (if any)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To view the commit history:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&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%2Fkrx4nd3p98dhe8ylynry.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%2Fkrx4nd3p98dhe8ylynry.png" alt="Image description" width="800" height="167"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Making Changes
&lt;/h2&gt;

&lt;p&gt;Edit &lt;code&gt;hello.txt&lt;/code&gt;, then check what changed:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&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%2F6xgy49w8n1qi1qyt2s1k.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%2F6xgy49w8n1qi1qyt2s1k.png" alt="git diff output" width="695" height="455"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Git tracks the difference between the working directory and staging area using metadata inside .git.&lt;/p&gt;




&lt;h2&gt;
  
  
  Diving into the Objects Folder
&lt;/h2&gt;

&lt;p&gt;Inside &lt;code&gt;.git/objects&lt;/code&gt;, Git stores:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Blobs (file content)&lt;/li&gt;
&lt;li&gt;Trees (directories)&lt;/li&gt;
&lt;li&gt;Commits (snapshots)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The folder names are based on the first 2 characters of the SHA-1 hash of the file or 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%2F4keqed4oj1vsaz80pbm1.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%2F4keqed4oj1vsaz80pbm1.png" alt=".git/objects structure" width="800" height="465"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Viewing Commit Data
&lt;/h2&gt;

&lt;p&gt;You can use the commit hash to view commit details:&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%2F2bdtp1jybkw6o92nc6nx.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%2F2bdtp1jybkw6o92nc6nx.png" alt="Image description" width="800" height="130"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Notice, I can now see the who committed details, using the commit Hash ID.&lt;/p&gt;

&lt;p&gt;Now I want to see the content in the file;&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%2Fck6zsfbmwgiax0c9wtet.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%2Fck6zsfbmwgiax0c9wtet.png" alt="Image description" width="800" height="42"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I will now use the blob ID to see the content in “file1.txt” that was committed.&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%2F37uam3fewv8ipoanv7r3.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%2F37uam3fewv8ipoanv7r3.png" alt="Image description" width="800" height="44"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Git stores everything in the .git folder — and you rarely need to manually look inside, because Git gives us tools like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;git stat&lt;/li&gt;
&lt;li&gt;git diff&lt;/li&gt;
&lt;li&gt;git log&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;
  
  
  Committing
&lt;/h2&gt;

&lt;p&gt;Create another file, say file2.txt, add some content, then:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git add file2.txt
git commit -m "Added file2.txt"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check the commit log again:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&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%2Ft1rnas5m5p7q9bhs7lke.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%2Ft1rnas5m5p7q9bhs7lke.png" alt="Image description" width="800" height="352"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You'll notice the HEAD is now pointing to the latest commit (Commit 2).&lt;/p&gt;




&lt;h2&gt;
  
  
  How Git Stores Commits
&lt;/h2&gt;

&lt;p&gt;Every commit contains a SHA-1 hash, generated based on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The content of the files&lt;/li&gt;
&lt;li&gt;Previous commit&lt;/li&gt;
&lt;li&gt;Commit message&lt;/li&gt;
&lt;li&gt;Metadata&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This ensures every commit is unique, even if you commit the same code again, you’ll likely get a different hash.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;🧠 Git = Content-addressable storage.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Fun Fact: Git Meets Algorithms
&lt;/h2&gt;

&lt;p&gt;Spotify once used an algorithm named MAYA (Most Advanced Yet Acceptable) to recommend music.&lt;br&gt;
While it was supposed to suggest songs related to your taste, a bug caused it to occasionally show completely unrelated tracks, and surprisingly, users loved the variety!&lt;/p&gt;

&lt;p&gt;Similarly, Git’s algorithms may look simple, but the power lies in how uniquely and efficiently it stores and suggests changes.&lt;/p&gt;


&lt;h2&gt;
  
  
  Traveling Between Commits
&lt;/h2&gt;

&lt;p&gt;To navigate through your commit history, first run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git log --oneline
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fxm55e4b6xn7g4b80lnia.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%2Fxm55e4b6xn7g4b80lnia.png" alt="Image description" width="652" height="175"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To compare differences between two commits:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git diff &amp;lt;commit1&amp;gt; &amp;lt;commit2&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2F9yutfmc6k900qc6fxpa2.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%2F9yutfmc6k900qc6fxpa2.png" alt="Image description" width="800" height="861"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Moving HEAD to a Previous Commit
&lt;/h2&gt;

&lt;p&gt;Want to move back in time?&lt;br&gt;
You can checkout an earlier commit using its hash:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&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%2Fzrsu41267v9899nsk8fe.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%2Fzrsu41267v9899nsk8fe.png" alt="Image description" width="800" height="286"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As we move the head to commit 1, the files that were in the latest commit (Commit 2) are in Changes now.  &lt;/p&gt;

&lt;p&gt;If you don't want the changes then;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git reset --hard &amp;lt;commit-hash&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fo6yfapvq7k1l20j3n83x.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%2Fo6yfapvq7k1l20j3n83x.png" alt="Image description" width="800" height="228"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Notice because file 2, was added after the second commit, it appears as a new Untracked file, even though it was committed. &lt;/p&gt;

&lt;p&gt;To verify:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&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%2F372aeqdkmlb2mfiiikut.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%2F372aeqdkmlb2mfiiikut.png" alt="Image description" width="800" height="194"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  GitHub: The Remote Repository
&lt;/h2&gt;

&lt;p&gt;Sharing the &lt;code&gt;.git&lt;/code&gt; folder allows others to see your commits. Instead, use &lt;strong&gt;GitHub&lt;/strong&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%2Fndwy2hb7xj00rw5c6i3y.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%2Fndwy2hb7xj00rw5c6i3y.png" alt="GitHub 1" width="800" height="269"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Initially both developers will have the same content in “file1.txt”. Now when they both begin to work on it simultaneously there will be conflicts as both as using the same file. Now which file is the Source Of Truth ? For that pen drive won’t be needed, we can use 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%2Fm7weq8tco67vgeyrrdwz.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%2Fm7weq8tco67vgeyrrdwz.png" alt="Github 2" width="800" height="235"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Create a GitHub repo (e.g. &lt;code&gt;Git-Masterclass&lt;/code&gt;)&lt;br&gt;&lt;br&gt;
Then, link your local project:&lt;/p&gt;

&lt;p&gt;Use the push an existing repository from the command line commands&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git remote add origin https://github.com/yourname/Git-Masterclass.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fdnteaywsaxzi3xdxuifi.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%2Fdnteaywsaxzi3xdxuifi.png" alt="Conflicting versions of the same file" width="800" height="20"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Verify the remote was added by viewing the config file within the .git folder&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%2Fpxzhutgay67cugaj75nw.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%2Fpxzhutgay67cugaj75nw.png" alt="Remote URL added" width="800" height="349"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To see the URLS of the remotes connected to the local git repository, both for fetching(pull) and pushing.&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%2Flnod1c1um69xzb9t6crj.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%2Flnod1c1um69xzb9t6crj.png" alt="Checking config file" width="800" height="84"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Follow the remaining commands on GitHub:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git branch -M main git push -u origin main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fuslvk2j2onhbyhiw31cm.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%2Fuslvk2j2onhbyhiw31cm.png" alt="git remote -v output" width="800" height="256"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now visit Github will be able to see “Commit 1”, which was on our local machine is now on 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%2F8fy7kaccncz8w217zh6r.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%2F8fy7kaccncz8w217zh6r.png" alt="Commit now visible on GitHub" width="800" height="196"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Wrapping Up
&lt;/h2&gt;

&lt;p&gt;In this post, you learned how:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How Git tracks and stages files
&lt;/li&gt;
&lt;li&gt;How commits and hashes work
&lt;/li&gt;
&lt;li&gt;What lives inside the &lt;code&gt;.git&lt;/code&gt; folder
&lt;/li&gt;
&lt;li&gt;How to view, reset, and compare commits
&lt;/li&gt;
&lt;li&gt;How to push changes to GitHub&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  📚 More from the Series
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://dev.to/shanedsouza4/commit-to-code-why-git-github-matter-4llf"&gt;Part 1: Why Git &amp;amp; GitHub Matter&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/shanedsouza4/commit-to-code-setting-up-git-and-github-4o2b"&gt;Part 2: Setting Up Git and GitHub&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;✅ Part 3: &lt;em&gt;You're here!&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/shanedsouza4/commit-to-code-branching-merging-squashing-rebasing-3b64"&gt;Part 4: Branching, Merging, Squashing &amp;amp; Rebasing&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/shanedsouza4/commit-to-code-working-with-pull-requests-conflict-resolution-4a9j"&gt;Part 5: Working with Pull Requests &amp;amp; Conflict Resolution&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;Enjoyed this?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Let me know in the comments or follow me for the next post in this Git &amp;amp; GitHub series!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://shanedsouza.com/" rel="noopener noreferrer"&gt;shanedsouza.com&lt;/a&gt;&lt;/p&gt;

</description>
      <category>git</category>
      <category>github</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>Commit to Code: Setting Up Git and GitHub</title>
      <dc:creator>Shane Dsouza</dc:creator>
      <pubDate>Sun, 20 Apr 2025 02:21:11 +0000</pubDate>
      <link>https://dev.to/shanedsouza4/commit-to-code-setting-up-git-and-github-4o2b</link>
      <guid>https://dev.to/shanedsouza4/commit-to-code-setting-up-git-and-github-4o2b</guid>
      <description>&lt;p&gt;&lt;strong&gt;Git &amp;amp; GitHub Series&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
➡️ &lt;em&gt;You're reading Part 2&lt;/em&gt;&lt;br&gt;&lt;br&gt;
⬅️ &lt;a href="https://dev.to/shanedsouza4/commit-to-code-why-git-github-matter-4llf"&gt;Part 1: Why Git &amp;amp; GitHub Matter&lt;/a&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  Installation and Setup
&lt;/h2&gt;

&lt;p&gt;In this part of the series, we’ll walk through installing Git on your system, setting up your identity, and creating a GitHub account, everything you need to start tracking and sharing your code.&lt;/p&gt;


&lt;h2&gt;
  
  
  1. Installing Git
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Windows
&lt;/h3&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%2Fy94ry1knoibd4rn0sptk.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%2Fy94ry1knoibd4rn0sptk.png" alt="Git installation wizard on Windows" width="800" height="564"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Go to &lt;a href="https://git-scm.com" rel="noopener noreferrer"&gt;git-scm.com&lt;/a&gt; and download the &lt;strong&gt;Windows installer&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Run the installer and click &lt;strong&gt;Next&lt;/strong&gt; through the setup wizard (default settings are fine).&lt;/li&gt;
&lt;li&gt;Choose &lt;strong&gt;Git Bash&lt;/strong&gt; as your default terminal.&lt;/li&gt;
&lt;li&gt;Finish the installation and verify Git was installed:
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git --version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  macOS
&lt;/h3&gt;

&lt;p&gt;Option 1 – Install via Xcode CLI:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;xcode-select --install
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Option 2 – Using Homebrew:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew install git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Verify installation:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;






&lt;h2&gt;
  
  
  2. Configuring Git with Your Identity
&lt;/h2&gt;

&lt;p&gt;Once Git is installed, you should set your username and email. This information will be attached to your commits.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To verify your settings:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;This ensures that every commit you make is properly attributed to you, which is especially important when collaborating.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. Creating a GitHub Account
&lt;/h2&gt;

&lt;p&gt;If you don’t already have a 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%2Frzv5fgxdqw8nvn0t3gcb.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%2Frzv5fgxdqw8nvn0t3gcb.png" alt="Github Signup Page" width="800" height="376"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Visit &lt;a href="https://github.com/join" rel="noopener noreferrer"&gt;https://github.com/join&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Choose a username, enter your email address, and create a password&lt;/li&gt;
&lt;li&gt;Follow the prompts to verify your email and complete your profile
Once you’re signed in, you’ll be ready to start creating repositories and pushing code to GitHub.&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;You're All Set!&lt;br&gt;
You now have:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Git installed&lt;/li&gt;
&lt;li&gt;Your identity configured&lt;/li&gt;
&lt;li&gt;A GitHub account ready to go&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  📚 More from the Series
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://dev.to/shanedsouza4/commit-to-code-why-git-github-matter-4llf"&gt;Part 1: Why Git &amp;amp; GitHub Matter&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;✅ Part 2: &lt;em&gt;You're here!&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/shanedsouza4/commit-to-code-creating-commits-exploring-the-git-folder-pno"&gt;Part 3: Creating Commits &amp;amp; Exploring the .git Folder&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/shanedsouza4/commit-to-code-branching-merging-squashing-rebasing-3b64"&gt;Part 4: Branching, Merging, Squashing &amp;amp; Rebasing&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/shanedsouza4/commit-to-code-working-with-pull-requests-conflict-resolution-4a9j"&gt;Part 5: Working with Pull Requests &amp;amp; Conflict Resolution&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;Enjoyed this?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Let me know in the comments or follow me for the next post in this Git &amp;amp; GitHub series!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://shanedsouza.com/" rel="noopener noreferrer"&gt;shanedsouza.com&lt;/a&gt;&lt;/p&gt;

</description>
      <category>git</category>
      <category>github</category>
      <category>programming</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Commit to Code: Why Git &amp; GitHub Matter</title>
      <dc:creator>Shane Dsouza</dc:creator>
      <pubDate>Sun, 20 Apr 2025 01:01:02 +0000</pubDate>
      <link>https://dev.to/shanedsouza4/commit-to-code-why-git-github-matter-4llf</link>
      <guid>https://dev.to/shanedsouza4/commit-to-code-why-git-github-matter-4llf</guid>
      <description>&lt;p&gt;📚 &lt;strong&gt;Git &amp;amp; GitHub Series&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
➡️ &lt;em&gt;You're reading Part 1&lt;/em&gt;&lt;br&gt;&lt;br&gt;
⏭️ Next up: &lt;a href="https://dev.to/shanedsouza4/commit-to-code-setting-up-git-and-github-4o2b"&gt;Part 2 – Setting Up Git &amp;amp; Your First Commit&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Think Google Docs, but for code.&lt;/strong&gt; It automatically saves your work, tracks every change, and makes collaboration effortless, all without the fear of losing progress. Now imagine trying to code without a system like that. Sounds chaotic, right?&lt;/p&gt;

&lt;p&gt;That’s exactly why &lt;strong&gt;Git&lt;/strong&gt; and &lt;strong&gt;GitHub&lt;/strong&gt; are essential in modern development. They make it easier to track changes, collaborate with teams, and avoid costly mistakes, like accidentally deleting an important file.&lt;/p&gt;




&lt;h2&gt;
  
  
  Git: Code Management
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Git&lt;/strong&gt; is a version control system that helps developers track and manage code changes over time.&lt;/p&gt;

&lt;p&gt;It records each change like a timeline, making it easy to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Review changes&lt;/li&gt;
&lt;li&gt;Compare versions&lt;/li&gt;
&lt;li&gt;Revert when something breaks&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Example:&lt;/em&gt;&lt;br&gt;&lt;br&gt;
If a bug appears in version 90, you can quickly roll back to version 89 where everything worked just fine.&lt;/p&gt;

&lt;p&gt;While other version control systems exist, Git has become the &lt;strong&gt;industry standard&lt;/strong&gt; — known for its speed, flexibility, and massive community support.&lt;/p&gt;




&lt;h2&gt;
  
  
  GitHub: A Collaboration Platform &amp;amp; CLI Tool
&lt;/h2&gt;

&lt;p&gt;When multiple developers work on the same project, things can get messy fast.&lt;/p&gt;

&lt;p&gt;Let’s say Developer A and Developer B are both editing the same file with different functions. How do we avoid chaos and ensure everyone stays in sync?&lt;/p&gt;

&lt;p&gt;We use a &lt;strong&gt;Single Source of Truth&lt;/strong&gt;.&lt;/p&gt;




&lt;h3&gt;
  
  
  Single Source of Truth
&lt;/h3&gt;

&lt;p&gt;A &lt;em&gt;Single Source of Truth&lt;/em&gt; is a &lt;strong&gt;remote Git server&lt;/strong&gt; that holds the official version of the code.&lt;/p&gt;

&lt;p&gt;It can be hosted on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;AWS&lt;/li&gt;
&lt;li&gt;Azure&lt;/li&gt;
&lt;li&gt;Any remote machine with Git installed&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Developers &lt;strong&gt;push&lt;/strong&gt; their changes to this central server, and others &lt;strong&gt;pull&lt;/strong&gt; the latest updates — keeping everyone aligned.&lt;/p&gt;




&lt;h3&gt;
  
  
  Public Git Servers
&lt;/h3&gt;

&lt;p&gt;Instead of setting up your own server, you can use public platforms like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;GitHub&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;GitLab&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Bitbucket&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;They’re powered by Git, but built for modern collaboration.&lt;/p&gt;




&lt;h2&gt;
  
  
  Working with GitHub
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;GitHub&lt;/strong&gt; is a cloud-based platform where developers store and manage their code in repositories.&lt;/p&gt;

&lt;p&gt;Think of a &lt;strong&gt;repository&lt;/strong&gt; as a folder for your project — complete with code, history, and documentation.&lt;/p&gt;

&lt;p&gt;Developers can &lt;strong&gt;pull&lt;/strong&gt; code from these repositories to work on it locally, and once they’re done, they &lt;strong&gt;push&lt;/strong&gt; the changes back to the repository with a message. This message records who made the change ("Developer A worked on this") and what was done, this action is called a &lt;strong&gt;commit&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This transparency allows teams to collaborate confidently, knowing exactly &lt;strong&gt;what&lt;/strong&gt; changed, &lt;strong&gt;when&lt;/strong&gt;, and &lt;strong&gt;by whom&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Wrapping Up
&lt;/h2&gt;

&lt;p&gt;This is just the beginning of your journey with Git and GitHub.&lt;/p&gt;

&lt;p&gt;In this article, you discovered &lt;strong&gt;what&lt;/strong&gt; Git and GitHub are, and &lt;strong&gt;why&lt;/strong&gt; they matter.&lt;/p&gt;




&lt;h3&gt;
  
  
  📚 More from the Series
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;✅ Part 1: &lt;em&gt;You're here!&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/shanedsouza4/commit-to-code-setting-up-git-and-github-4o2b"&gt;Part 2: Setting Up Git and GitHub&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/shanedsouza4/commit-to-code-creating-commits-exploring-the-git-folder-pno"&gt;Part 3: Creating Commits &amp;amp; Exploring the .git Folder&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/shanedsouza4/commit-to-code-branching-merging-squashing-rebasing-3b64"&gt;Part 4: Branching, Merging, Squashing &amp;amp; Rebasing&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/shanedsouza4/commit-to-code-working-with-pull-requests-conflict-resolution-4a9j"&gt;Part 5: Working with Pull Requests &amp;amp; Conflict Resolution&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;Enjoyed this?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Let me know in the comments or follow me for the next post in this Git &amp;amp; GitHub series!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://shanedsouza.com/" rel="noopener noreferrer"&gt;shanedsouza.com&lt;/a&gt;&lt;/p&gt;

</description>
      <category>git</category>
      <category>github</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
