<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Coder Legion - Recent posts tagged branching</title>
<link>https://coderlegion.com/tag/branching</link>
<description>Powered by Question2Answer</description>
<item>
<title>Branching Strategies</title>
<link>https://coderlegion.com/21256/branching-strategies</link>
<description>&lt;p&gt;Tony Kelly hosts our latest episode of Continuous Delivery Office Hours, with Bob Walker and Steve Fenton.&lt;/p&gt;
&lt;p&gt;Your branching strategy can support Continuous Delivery, or make it an impossible goal. Teams should assess the impact of how they branch on their ability to deliver software at all times, and that means there are some branching techniques that make software delivery more like walking in the dark through a field of rakes.&lt;/p&gt;
&lt;p&gt;Listen now to discover:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The best branching strategies&lt;/li&gt;
&lt;li&gt;The worst possible branching strategy&lt;/li&gt;
&lt;li&gt;How branching fits into Continuous Delivery&lt;/li&gt;
&lt;li&gt;Confessions from our worst merges&lt;/li&gt;
&lt;/ul&gt;
</description>
<category>Videos</category>
<guid isPermaLink="true">https://coderlegion.com/21256/branching-strategies</guid>
<pubDate>Wed, 08 Jul 2026 09:00:00 +0000</pubDate>
</item>
<item>
<title>Learn Git fast as if your job depends on it</title>
<link>https://coderlegion.com/11776/learn-git-fast-as-if-your-job-depends-on-it</link>
<description>&lt;h3 id=&quot;tl-dr&quot;&gt;TL;DR&lt;/h3&gt;
&lt;p&gt;In this post, with a grain of humor, I'm going to show you the minimum number of Git commands that you need to learn in order to start being productive and get that code from your machine to the company Git server. Also, I'll cover a bit of theory and Git installation as well.&lt;/p&gt;
&lt;h3 id=&quot;disclaimer&quot;&gt;Disclaimer&lt;/h3&gt;
&lt;blockquote&gt;&lt;p&gt;⚠️ Nobody in this story, and no outfit or corporation, thank God, is based upon an actual person or outfit in the real world. But I can tell you this; as my journey through the software jungle progressed, I came to realize that, by comparison with the reality, my story was as tame as a holiday postcard. ~ John le Carré&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 id=&quot;setting-the-stage&quot;&gt;Setting the stage&lt;/h3&gt;
&lt;p&gt;So, let's set a scene; it's your first day as a junior developer straight out of college. You get to work, greet your superior that's supposed to be responsible for you, and since he's too busy with putting down some fire that just popped up, he, conversely, while you're trying to keep up walking aside him tells you something like:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;I've set the Git access for you to my website project.&lt;/p&gt;
&lt;p&gt;You have a ticket in our project management tool assigned to you. No worries, it's just some simple stuff that needs to be changed.&lt;/p&gt;
&lt;p&gt;Just check the email details, and you can start immediately.&lt;/p&gt;
&lt;p&gt;I'm aware that you may not be familiar with Git. I'm not trying to be an asshole, but just deal with it, learn it, OK? Don't they, like, teach you kids nothing in school these days?&lt;/p&gt;
&lt;p&gt;Ah, I gotta run.&lt;/p&gt;
&lt;p&gt;Oh, and one more thing, look up branching and do not EVER, and I repeat - EVER, commit to master; do a PR instead! Good luck and see ya later!&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;OK. You sit down at your cubicle, open up your email client, log in, and there you see the email (without the subject line, of course) with the contents:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/Hitman666/MrSupervisorWebsite&quot;&gt;Here's a link to the Git repo on Github&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Good luck,&lt;br&gt;
Mr. Superior&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 id=&quot;reality-sets-in&quot;&gt;Reality sets in&lt;/h3&gt;
&lt;blockquote&gt;&lt;p&gt;⚠️ This, in and of itself is a poor onboarding if you ask me, but I personally have seen it way too many times, so here are the things you need to do to get productive fast and learn the ropes as fast as you can.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;So now you're, in lack of better words, screwed (you know the exact word, but we're not supposed to be using profanity here, ae?).&lt;/p&gt;
&lt;p&gt;You're lost. You heard about Git before, but you never used it. Now you're kicking yourself for not learning it properly yourself. But, it is what it is, and since you're really determined to make it in this 'programming' world, you're ready to do what it takes.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://i.imgur.com/YZ4W1Ao.jpg&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;I would question the fact that if you are 'so into it', how come you haven't learned it yet, but as Mr. Superior said, I'm not trying to be an asshole&lt;/em&gt; &lt;/p&gt;
&lt;p&gt;Therefore, buckle up young padawan, you're in for a ride!&lt;/p&gt;
&lt;h3 id=&quot;what-is-this-git-thing-&quot;&gt;What is this Git thing?&lt;/h3&gt;
&lt;p&gt;First, let me start off with a few problems:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Say you're writing a seminar and you make some changes, save them, go out of the text editor, come back, and you want to see all of your changes that you did last in the file. Or, for example, you want to undo some changes that you did last night (writing a seminar after returning from a party is a noble act, but not a very smart one!).&lt;/li&gt;
&lt;li&gt;While writing this seminar you create several versions of the same file and you don't even know what's changed in which version; you would really love to know what was, for example, changed in this current version based on the, say, a version from a few days ago.&lt;/li&gt;
&lt;li&gt;You're working on a group project and someone deletes your changes 'by accident'.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://en.wikipedia.org/wiki/Version_control&quot;&gt;VCS&lt;/a&gt; (Version Control Systems) tends to solve these problems. And, let me start off by saying that no, you don't need to use VCS &lt;em&gt;only&lt;/em&gt; for writing code (thus the seminar example). You can use it for any textual project. One of VCS solutions is &lt;a rel=&quot;nofollow&quot; href=&quot;https://git-scm.com/&quot;&gt;Git&lt;/a&gt;. One other popular VCS, that's still used to some extent today is &lt;a rel=&quot;nofollow&quot; href=&quot;https://subversion.apache.org/&quot;&gt;Subversion&lt;/a&gt;. You can see a detailed list of Version Control Systems &lt;a rel=&quot;nofollow&quot; href=&quot;https://en.wikipedia.org/wiki/List_of_version_control_software&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Git was made by the ever so slightly genius Linus Torvalds, the father of Linux:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://i.imgur.com/ESoSiQq.jpg&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;Git is a distributed version control system (VCS).&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Version control&lt;/strong&gt; means that you use it to store versions of your documents. True, it seems it's very popular among developers, but designers and other people (that are a bit more tech savvy) also use it to track versions of their files.&lt;/p&gt;
&lt;p&gt;This whole &lt;strong&gt;distributed&lt;/strong&gt; part is one of the things that makes it different from other VCS. Rather than have only one single place for the full version history of the software, as is common in once-popular VCS like CVS or Subversion, in Git every developer's working copy is also a repository that can contain the &lt;strong&gt;full history of all changes&lt;/strong&gt;.&lt;/p&gt;
&lt;h3 id=&quot;ok-but-what-is-github-&quot;&gt;OK, but what is Github?&lt;/h3&gt;
&lt;blockquote&gt;&lt;p&gt;Something like Dropbox, but customized for Git.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/&quot;&gt;Github&lt;/a&gt; is a hosting service for Git projects, with some additional batteries included that we're not going to get into at this point, as you're short on time. Think of it as a place where you store your Git 'stuff'.&lt;/p&gt;
&lt;h3 id=&quot;installing-git&quot;&gt;Installing Git&lt;/h3&gt;
&lt;p&gt;To install Git, go to the &lt;a rel=&quot;nofollow&quot; href=&quot;https://try.github.io/&quot;&gt;official website&lt;/a&gt; and download the executable for your machine. I'm not going into the installation details as they're really just a bunch of &lt;code&gt;Next, Next, Next, yes to malware, Finish&lt;/code&gt; set of steps. &lt;em&gt;I'm kidding about the malware OFC&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;To make sure your installation was successful, run the following command in your Terminal/Command prompt:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;git --version&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;You should get something like:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;git version 2.10.1&lt;/code&gt;&lt;/p&gt;
&lt;h3 id=&quot;fetching-the-repo&quot;&gt;Fetching the repo&lt;/h3&gt;
&lt;p&gt;OK, so let's finally get some action. In your email, you received an URL to the Git repository. It was this: &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/Hitman666/MrSupervisorWebsite&quot;&gt;https://github.com/Hitman666/MrSupervisorWebsite&lt;/a&gt;. You click the link, and you see something like this:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://i.imgur.com/nvz9ulq.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;Click the &lt;code&gt;Clone or download&lt;/code&gt; button, make sure you see the &lt;code&gt;Use SSH&lt;/code&gt; in the top right corner of a popup and copy the link.&lt;/p&gt;
&lt;p&gt;To get this repository to your computer, you have to execute the following command in your Terminal/Command prompt (I'll use Terminal in the rest of the post):&lt;/p&gt;
&lt;p&gt;&lt;code&gt;git clone https://github.com/Hitman666/MrSupervisorWebsite.git&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;The output of the command should look something like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Cloning into 'MrSupervisorWebsite'...
remote: Counting objects: 7, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 7 (delta 0), reused 7 (delta 0), pack-reused 0
Receiving objects: 100% (7/7), done.
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;checking-out-the-code&quot;&gt;Checking out the code&lt;/h3&gt;
&lt;p&gt;Now, go into the newly created &lt;code&gt;MrSupervisorWebsite&lt;/code&gt; folder and open it in your editor.&lt;/p&gt;
&lt;p&gt;You should see three files: &lt;code&gt;index.htmnl&lt;/code&gt;, &lt;code&gt;style.css&lt;/code&gt;, and &lt;code&gt;README.md&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;You quickly go and click to open the &lt;code&gt;README.md&lt;/code&gt; file, but all you see is this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# MrSupervisorWebsite
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Hmm, so, no help there.&lt;/p&gt;
&lt;p&gt;You open up the &lt;code&gt;index.html&lt;/code&gt; file and you see:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang=&quot;en&quot;&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset=&quot;UTF-8&quot;&amp;gt;
    &amp;lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&amp;gt;
    &amp;lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;ie=edge&quot;&amp;gt;
    &amp;lt;title&amp;gt;MrSupervisorWebsite&amp;lt;/title&amp;gt;
    &amp;lt;link rel=&quot;stylesheet&quot; href=&quot;style.css&quot;&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;h1 class=&quot;title&quot;&amp;gt;Welcome to MrSupervisorWebsite!&amp;lt;/h1&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;OK, finally something that you're familiar with! You also open up the &lt;code&gt;style.css&lt;/code&gt; file, and you see:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;.title {
    color: blue;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Next, you take a look at the ticket assigned to you in the project management tool that Mr.Superior mentioned, and it looks something like:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://i.imgur.com/UV33DqY.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;You take a deep breath, finally something that you know how to handle! &lt;/p&gt;
&lt;p&gt;You're a bit taken aback by the 'manly color', so you go and ask Google:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://i.imgur.com/lgoY0Ui.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;You pick the &lt;code&gt;4872A2,&lt;/code&gt; and you're happy. You think to yourself: OK, now I just need to change this color in the &lt;code&gt;style.css&lt;/code&gt; file, somehow add this to this Git thing and 'publish' it.&lt;/p&gt;
&lt;p&gt;You're right, but not so fast! You remember that note from Mr.Supervisor that you shouldn't commit to master, EVER?&lt;/p&gt;
&lt;h3 id=&quot;creating-a-new-branch&quot;&gt;Creating a new branch&lt;/h3&gt;
&lt;p&gt;So, what is this &lt;code&gt;master&lt;/code&gt; anyway? You go online, and you find that:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;Git has branches, and its main one is called &lt;code&gt;master&lt;/code&gt;. You can create as many of them as you want, based on any other existing one.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Also, you read a bit about the PR, and you learn that:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;PR is short for Pull Request. Pull requests let you tell others about changes you've pushed to a repository on GitHub. Once a pull request is opened, you can discuss and review the potential changes with collaborators and add follow-up commits before the changes are merged into the repository.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;So, this is smart, right? You can add your code to the Git repo without breaking any existing stuff on the &lt;code&gt;master&lt;/code&gt; branch, and through this PR you can then ask a more experienced developer to do a CR (code review) on your PR and accept it or not.&lt;/p&gt;
&lt;p&gt;You're smart; you see the huge benefit of this vs. just committing something to &lt;code&gt;master&lt;/code&gt; and potentially breaking something in production.&lt;/p&gt;
&lt;p&gt;Now, to circle back a bit and explain how could it be that you would break something!? Well, there's a thing called CI (Continuous Integration) and CD (Continuous Deployment), and you can read more about it, but in essence, it's this:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;Every time someone pushes a new commit to &lt;code&gt;master&lt;/code&gt; branch, a whole set of deploy scripts are being triggered, and essentially the new code that's pushed is going to appear in production.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;What this means is that if you change that color and you commit it to &lt;code&gt;master&lt;/code&gt; (you'll learn in a minute how to actually do this &lt;code&gt;commit&lt;/code&gt; action), it will 'automagically' appear in the production on the website.&lt;/p&gt;
&lt;p&gt;⚠️ Of course, the premise is that the service is set like that in the first place.&lt;/p&gt;
&lt;p&gt;So, you get the point and value of additional branches, and you &lt;strong&gt;create a new branch&lt;/strong&gt; by executing the following command in your Terminal:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;git checkout -b poppingTitle&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;The upper command is a shortcut for two commands:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;git branch poppingTitle
git checkout poppingTitle
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The first one creates a new branch called &lt;code&gt;poppingTitle&lt;/code&gt; from the current branch that you're on (in our case that's &lt;code&gt;master&lt;/code&gt;). The second one 'checks it out'. Meaning, it places you on that branch.&lt;/p&gt;
&lt;h3 id=&quot;adding-some-code&quot;&gt;Adding some code&lt;/h3&gt;
&lt;p&gt;Now you're finally ready to add some code!&lt;/p&gt;
&lt;p&gt;Open up the &lt;code&gt;style.css&lt;/code&gt; file, change the color, and save the file. It should look like this now:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;.title {
    color: #4872A2;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;One useful command that you'll use a lot is &lt;code&gt;git status&lt;/code&gt;, which will you tell you the status of your git project. If you execute that in your Terminal you will see that the &lt;code&gt;style.css&lt;/code&gt; file was modified:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;On branch poppingTitle
Changes not staged for commit:
  (use &quot;git add &amp;lt;file&amp;gt;...&quot; to update what will be committed)
  (use &quot;git checkout -- &amp;lt;file&amp;gt;...&quot; to discard changes in working directory)

    modified:   style.css

no changes added to commit (use &quot;git add&quot; and/or &quot;git commit -a&quot;)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As you can see, in the instructions from the output, these changes are not yet added to the commit. To do that, execute the command &lt;code&gt;git add style.css&lt;/code&gt;. Of course, if you were to have multiple files you would not have to list each and every one of them, you would just use &lt;code&gt;git add .&lt;/code&gt; command.&lt;/p&gt;
&lt;p&gt;If you run the &lt;code&gt;git status&lt;/code&gt; command again, you'll see that we have changes that are ready to be committed: &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;On branch poppingTitle
Changes to be committed:
  (use &quot;git reset HEAD &amp;lt;file&amp;gt;...&quot; to unstage)

    modified:   style.css
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;committing-code&quot;&gt;Committing code&lt;/h3&gt;
&lt;p&gt;To commit (one could use words like save or apply here for better clarity) the added changes to your local repository, just run:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;git commit -m &quot;Changed the title color&quot;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Of course, the commit message can be anything, but please do yourself a favor and write meaningful commit messages.&lt;/p&gt;
&lt;p&gt;If you run the &lt;code&gt;git status&lt;/code&gt; command again, you'll see that we have a clean repository:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;On branch poppingTitle
nothing to commit, working tree clean
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;pushing-to-a-remote-repository&quot;&gt;Pushing to a remote repository&lt;/h3&gt;
&lt;p&gt;So, great, at this point you have the change locally in your repository, but you'd like to get this back to Github (the so-called remote repository, or &lt;code&gt;origin&lt;/code&gt; as it's usually referred to).&lt;/p&gt;
&lt;p&gt;For that you have to execute the following command:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;git push origin poppingTitle&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;You should get an output similar to this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Counting objects: 3, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 299 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To github.com:Hitman666/MrSupervisorWebsite.git
 * [new branch]      poppingTitle -&amp;gt; poppingTitle
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;doing-a-pr&quot;&gt;Doing a PR&lt;/h3&gt;
&lt;p&gt;If you check Github now, you'll see that we've pushed this new branch:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://i.imgur.com/hoaLPE4.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;Now, click on the &lt;code&gt;Compare &amp;amp; pull request&lt;/code&gt; button.&lt;/p&gt;
&lt;p&gt;Here you can add some comment summarizing your pull request:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://i.imgur.com/NZDFScl.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;Finally, click the &lt;code&gt;Create pull request&lt;/code&gt; button.&lt;/p&gt;
&lt;p&gt;And now (if we're playing by the book) someone else from your team would come and review your code. At this point, you could let someone know about this via your Project Management Tool (JIRA, Trello, Leankit, Kanbanflow, etc...) by putting this task/card in the appropriate column.&lt;/p&gt;
&lt;h3 id=&quot;your-pr-is-accepted&quot;&gt;Your PR is accepted&lt;/h3&gt;
&lt;p&gt;When the pull request is approved (you get a notification from Github when someone approves or rejects it), you as the author go back to Github and just click on the &lt;code&gt;Merge pull request&lt;/code&gt; button, and that's it:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://i.imgur.com/oDzK7ZE.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;Finally, click the &lt;code&gt;Delete branch&lt;/code&gt; button as it's a good practice to not keep the merged branches in the remote repo:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://i.imgur.com/2XZfov5.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;h3 id=&quot;you-get-to-live-another-day&quot;&gt;You get to live another day&lt;/h3&gt;
&lt;p&gt;Your merge to &lt;code&gt;master&lt;/code&gt; goes well, it's auto-deployed, you check the website and all is cool. You update the ticket in your ticketing system by placing it in the 'Deployed' column (or some similarly named column). &lt;/p&gt;
&lt;p&gt;It's 17:12, you close your laptop and cheerfully go home to learn more about this awesome Git thingy. &lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://i.imgur.com/0jaodld.jpg&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
</description>
<category>Tutorials</category>
<guid isPermaLink="true">https://coderlegion.com/11776/learn-git-fast-as-if-your-job-depends-on-it</guid>
<pubDate>Mon, 16 Feb 2026 19:40:07 +0000</pubDate>
</item>
<item>
<title>Git Deep Dive: Mastering rerere</title>
<link>https://coderlegion.com/7273/git-deep-dive-mastering-rerere</link>
<description>&lt;p&gt;No, It's Not a Typo: Let's Talk About &lt;code&gt;git rerere&lt;/code&gt; (Reuse Recorded Resolution)&lt;/p&gt;
&lt;p&gt;&lt;code&gt;git rerere&lt;/code&gt; helps Git remember how you resolved a conflict previously, and automatically reuses that resolution when the same conflict occurs again. This can be a huge time-saver with recurring merge conflicts.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;how-to-enabled-it&quot;&gt;How to enabled it&lt;/h3&gt;
&lt;p&gt;Globally:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;git config --global rerere.enabled true
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Per project:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;git config rerere.enabled true
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Check status:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;git config --get rerere.enabled
&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;h3 id=&quot;example&quot;&gt;Example&lt;/h3&gt;
&lt;p&gt;I'm updating &lt;code&gt;hello.txt&lt;/code&gt; on &lt;code&gt;main&lt;/code&gt; and &lt;code&gt;feature/earth&lt;/code&gt; branch.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-txt&quot;&gt;Hello!
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;On &lt;code&gt;main&lt;/code&gt; branch:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-txt&quot;&gt;Hello World!
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;On &lt;code&gt;feature/earth&lt;/code&gt; branch:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-txt&quot;&gt;Hello Earth!
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now, if we try to merge &lt;code&gt;feature/earth&lt;/code&gt; into &lt;code&gt;main&lt;/code&gt;, we’ll get a conflict:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;git checkout main
git merge feature/earth
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Conflict:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-diff&quot;&gt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; HEAD
Hello World!
=======
Hello Earth!
&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; feature/earth
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We edit the file to:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-txt&quot;&gt;Hello Universe!
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then stage and commit:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;git add hello.txt
git commit
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Git will record the resolution:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Recorded resolution for 'hello.txt'.
[main 7fd7eda] Merge branch 'feature/earth'
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Next time Git encounters the same conflict, it will automatically reuse the previous resolution:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;git merge feature/earth
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You got:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Auto-merging hello.txt
CONFLICT (content): Merge conflict in hello.txt
Resolved 'hello.txt' using previous resolution.
Automatic merge failed; fix conflicts and then commit the result.
&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;h3 id=&quot;useful-commands&quot;&gt;Useful commands&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# Manually trigger rerere
git rerere
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# Forget a recored resolution
git rerere forget &amp;lt;file&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# Check the rerere cache
ls .git/rr-cache/
cat .git/rr-cache/&amp;lt;conflict-id&amp;gt;/preimage
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you don’t want Git to auto-resolve using &lt;code&gt;rerere&lt;/code&gt;, you can reset the file:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;git checkout --conflict=merge &amp;lt;file&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;h3 id=&quot;advanced&quot;&gt;Advanced&lt;/h3&gt;
&lt;p&gt;When Git detects a conflict during a merge or rebase, it generates a hash key based on the conflicting content — this becomes the &lt;code&gt;conflict-id&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Git then stores:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The &lt;strong&gt;preimage&lt;/strong&gt; (conflicted content)&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;postimage&lt;/strong&gt; (your resolved version)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;These are saved under &lt;code&gt;.git/rr-cache/&lt;/code&gt;.&lt;/p&gt;
&lt;h4 id=&quot;file-structure-&quot;&gt;File Structure:&lt;/h4&gt;
&lt;pre&gt;&lt;code&gt;.git/
└── rr-cache/
    ├── &amp;lt;conflict-id&amp;gt;/
    │   ├── preimage      # The file before conflict resolution
    │   ├── postimage     # The file after conflict resolution
    │   └── thisimage     # Temporary file used during auto-resolution
&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;important-notes&quot;&gt;Important Notes&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;conflict-id&lt;/code&gt; is &lt;strong&gt;not&lt;/strong&gt; a Git object, even though it looks like one.&lt;/li&gt;
&lt;li&gt;It’s stored &lt;strong&gt;locally only&lt;/strong&gt; — it won’t be pushed to the remote.&lt;/li&gt;
&lt;li&gt;If you delete &lt;code&gt;.git/rr-cache&lt;/code&gt;, the resolution is &lt;strong&gt;gone forever&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h3 id=&quot;summary&quot;&gt;Summary&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;git rerere&lt;/code&gt; is a powerful but often overlooked tools. It can save you a lot of time when dealing with recurring merge conflicts.&lt;/p&gt;
</description>
<category>Full-stack Dev</category>
<guid isPermaLink="true">https://coderlegion.com/7273/git-deep-dive-mastering-rerere</guid>
<pubDate>Thu, 13 Nov 2025 01:38:15 +0000</pubDate>
</item>
<item>
<title>Mastering Collaborative Coding: A Deep Dive into Git Branching and Merging for Teams</title>
<link>https://coderlegion.com/3450/mastering-collaborative-coding-a-deep-dive-into-git-branching-and-merging-for-teams</link>
<description>&lt;p&gt;Let's imagine a scenario without Git first to see the problem, and then we'll see how branching and merging provide the perfect solution.&lt;/p&gt;
&lt;h4 id=&quot;the-problem-the-single-shared-document-nightmare&quot;&gt;The Problem: The &quot;Single Shared Document&quot; Nightmare&lt;/h4&gt;
&lt;p&gt;Imagine you and a colleague (let's call them Coder A and Coder B) need to edit the same file, &lt;code&gt;app.js&lt;/code&gt;.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Coder A&lt;/strong&gt; is adding a new user login feature.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Coder B&lt;/strong&gt; is adding a new search bar feature.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Without a system like Git, they might:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Both download &lt;code&gt;app.js&lt;/code&gt; to their computers.&lt;/li&gt;
&lt;li&gt;Coder A works for three hours and adds 50 lines of code for the login feature.&lt;/li&gt;
&lt;li&gt;Coder B works for three hours and adds 40 lines of code for the search bar, in some of the same places.&lt;/li&gt;
&lt;li&gt;Coder A uploads their new version of &lt;code&gt;app.js&lt;/code&gt; to the shared server first. The server now has the login feature.&lt;/li&gt;
&lt;li&gt;A minute later, Coder B uploads &lt;em&gt;their&lt;/em&gt; new version. &lt;strong&gt;This completely overwrites Coder A's work.&lt;/strong&gt; The login feature is gone, and only the search bar exists.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This is a classic &quot;last write wins&quot; problem. It leads to lost work, frustration, and a need for constant communication like, &quot;Hey, don't touch &lt;code&gt;app.js&lt;/code&gt; today, I'm working on it!&quot;—which completely kills productivity.&lt;/p&gt;
&lt;hr&gt;
&lt;h4 id=&quot;the-solution-git-s-branching-and-merging-workflow&quot;&gt;The Solution: Git's Branching and Merging Workflow&lt;/h4&gt;
&lt;p&gt;Git solves this with an elegant workflow that allows for safe, parallel development.&lt;/p&gt;
&lt;p&gt;Here’s how it helps your two coders working on the same file:&lt;/p&gt;
&lt;h5 id=&quot;1-the-stable-foundation-the-main-branch&quot;&gt;1. The Stable Foundation: The &lt;code&gt;main&lt;/code&gt; Branch&lt;/h5&gt;
&lt;p&gt;Think of the &lt;code&gt;main&lt;/code&gt; branch (sometimes called &lt;code&gt;master&lt;/code&gt;) as the official, stable, working version of your project. This is your &quot;source of truth.&quot; No one works directly on &lt;code&gt;main&lt;/code&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(main branch) A---B---C  (C is the latest stable version)
&lt;/code&gt;&lt;/pre&gt;
&lt;h5 id=&quot;2-branching-creating-isolated-sandboxes&quot;&gt;2. Branching: Creating Isolated Sandboxes&lt;/h5&gt;
&lt;p&gt;When Coder A and Coder B start their tasks, they each create a &lt;strong&gt;branch&lt;/strong&gt;. A branch is essentially a personal copy of the project at a specific point in time.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Coder A&lt;/strong&gt; creates a &lt;code&gt;login-feature&lt;/code&gt; branch.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Coder B&lt;/strong&gt; creates a &lt;code&gt;search-bar&lt;/code&gt; branch.&lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;code&gt;                  (login-feature branch)
                 /
(main branch) A---B---C
                 \
                  (search-bar branch)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now, they are working in &lt;strong&gt;complete isolation&lt;/strong&gt;. Any changes Coder A makes to &lt;code&gt;app.js&lt;/code&gt; on their &lt;code&gt;login-feature&lt;/code&gt; branch are invisible to Coder B, and vice-versa. They can both edit the same file without fear of overwriting each other's work.&lt;/p&gt;
&lt;h5 id=&quot;3-working-in-parallel&quot;&gt;3. Working in Parallel&lt;/h5&gt;
&lt;p&gt;Coder A adds commits to their branch, and Coder B adds commits to theirs. The project history now looks like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;                  D---E  (Coder A's login work)
                 /
(main branch) A---B---C
                 \
                  F---G  (Coder B's search bar work)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;main&lt;/code&gt; branch remains untouched and stable. If the CEO needs a demo, you can always rely on the code in &lt;code&gt;main&lt;/code&gt;.&lt;/p&gt;
&lt;h5 id=&quot;4-merging-combining-the-features&quot;&gt;4. Merging: Combining the Features&lt;/h5&gt;
&lt;p&gt;This is the magic step. When a feature is complete, it gets merged back into &lt;code&gt;main&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Scenario 1: Coder A finishes first.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Coder A opens a &lt;strong&gt;Pull Request&lt;/strong&gt; (or Merge Request), which is a formal way of saying, &quot;I'm done with my work on the &lt;code&gt;login-feature&lt;/code&gt; branch. Can someone please review it and approve merging it into &lt;code&gt;main&lt;/code&gt;?&quot;&lt;/p&gt;
&lt;p&gt;The team reviews the code, and it's approved. The merge happens.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;                  D---E
                 /     \
(main branch) A---B---C-------H  (H is the new &quot;merge commit&quot;)
                 \
                  F---G
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;main&lt;/code&gt; branch now contains the original code &lt;strong&gt;plus&lt;/strong&gt; Coder A's login feature.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Scenario 2: Coder B now wants to merge.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Coder B's &lt;code&gt;search-bar&lt;/code&gt; branch is now &quot;behind&quot; the &lt;code&gt;main&lt;/code&gt; branch. Before they can merge, they must first update their branch with the latest changes from &lt;code&gt;main&lt;/code&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# While on the search-bar branch
git pull origin main
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Git will now try to automatically merge the changes from &lt;code&gt;main&lt;/code&gt; (which include the login feature) into Coder B's branch.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The Easy Case (No Conflict):&lt;/strong&gt; If Coder A and Coder B worked on completely different parts of &lt;code&gt;app.js&lt;/code&gt; (e.g., A worked at the top, B worked at the bottom), Git will seamlessly merge the changes. No manual work needed.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The Harder Case (Merge Conflict):&lt;/strong&gt; If both coders edited the &lt;em&gt;exact same lines&lt;/em&gt; in &lt;code&gt;app.js&lt;/code&gt;, Git will pause and say, &quot;I don't know which version to keep. You, the human, need to decide.&quot; This is a &lt;strong&gt;merge conflict&lt;/strong&gt;. It will mark the file like this:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-javascript&quot;&gt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; HEAD
// Coder B's search bar code that conflicts
=======
// Coder A's login code that conflicts
&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; main
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Coder B then simply edits the file to resolve the conflict—they might keep their code, keep the other code, or combine them. Once resolved, they commit the file and can finish their merge. The key is that &lt;strong&gt;the conflict is handled by one developer on their own branch&lt;/strong&gt;, not on the &lt;code&gt;main&lt;/code&gt; branch where it could break things for everyone.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;summary-of-how-it-helps-&quot;&gt;Summary of How It Helps:&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Isolation:&lt;/strong&gt; Developers can work on new, experimental, or even broken code without affecting the stable &lt;code&gt;main&lt;/code&gt; codebase.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Parallel Development:&lt;/strong&gt; Multiple developers can work on the same file at the same time, dramatically increasing team velocity.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Structured Integration:&lt;/strong&gt; Merging (and Pull Requests) provides a formal process for code review and quality control before new code is added to the main project.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Conflict Management:&lt;/strong&gt; Git provides a clear and robust system for identifying and resolving conflicts when they inevitably occur, ensuring no work is accidentally lost.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In short, branching and merging transform a chaotic, error-prone process into a safe, organized, and highly efficient workflow, which is the foundation of modern collaborative software development.&lt;/p&gt;
</description>
<category>CI/CD Pipelines</category>
<guid isPermaLink="true">https://coderlegion.com/3450/mastering-collaborative-coding-a-deep-dive-into-git-branching-and-merging-for-teams</guid>
<pubDate>Tue, 24 Jun 2025 15:26:00 +0000</pubDate>
</item>
</channel>
</rss>