<?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: David Skeppstedt</title>
    <description>The latest articles on DEV Community by David Skeppstedt (@dskeppstedt).</description>
    <link>https://dev.to/dskeppstedt</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%2F2431527%2Fc4cc7b35-c1eb-4fe6-9e8d-e0dbd9f6ff3d.jpg</url>
      <title>DEV Community: David Skeppstedt</title>
      <link>https://dev.to/dskeppstedt</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dskeppstedt"/>
    <language>en</language>
    <item>
      <title>How to do git handover while doing remote mob programming?</title>
      <dc:creator>David Skeppstedt</dc:creator>
      <pubDate>Thu, 14 Nov 2024 10:10:24 +0000</pubDate>
      <link>https://dev.to/dskeppstedt/how-to-do-git-handover-while-doing-remote-mob-programming-4ea4</link>
      <guid>https://dev.to/dskeppstedt/how-to-do-git-handover-while-doing-remote-mob-programming-4ea4</guid>
      <description>&lt;p&gt;The ritual of handover via git in mob programming (or pair or other software teaming techniques) is crucial for keeping the focus and pace.&lt;/p&gt;

&lt;p&gt;If you often end up in messy situations caused by git, this is the guide for you!&lt;/p&gt;

&lt;p&gt;In a remote mob programming session the most common way of doing the handover is via git using a temporary branch in origin as synchronization point. There is even a good tool built for this called mob.sh.&lt;/p&gt;

&lt;p&gt;However, in this post, we will focus on how to do it ourselves.&lt;/p&gt;

&lt;h2&gt;
  
  
  Git – Keep it simple
&lt;/h2&gt;

&lt;p&gt;I cannot stress this enough. Keep it simple should be the leading idea when doing handovers. As soon as you try to get fancy with git, you increase the risk of messing up and that the team loses focus.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Create a branch named wip
&lt;/h2&gt;

&lt;p&gt;The name is really not that important, you can call it &lt;code&gt;mob&lt;/code&gt; or &lt;code&gt;asdf&lt;/code&gt;. &lt;br&gt;
 &lt;br&gt;
The important thing it should be easy to say and type, and it should be short.  &lt;br&gt;
 &lt;br&gt;
This makes it easier for everyone in a &lt;em&gt;remote&lt;/em&gt; call to &lt;em&gt;hear&lt;/em&gt; the name of the branch and be able to check it out.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;To create a 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 switch -c wip
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. Push the branch
&lt;/h2&gt;

&lt;p&gt;The first driver of the session creates the branch and pushes it.  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;To push the branch write:&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 push origin wip
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  3. Everyone else switch to the wip branch
&lt;/h2&gt;

&lt;p&gt;Now it’s a good time for everyone else in the rotation to fetch the &lt;code&gt;wip&lt;/code&gt; branch to make it easier during handovers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Simple write the following command:&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 switch -c wip origin/wip
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  4. Code
&lt;/h2&gt;

&lt;p&gt;Start the timer and start implementing the code!&lt;/p&gt;

&lt;p&gt;There are a lot of different timer apps out there, I’m building a timer app called &lt;a href="https://remobster.io" rel="noopener noreferrer"&gt;Remobster&lt;/a&gt;, if you are interested in checking it out, sign up for the waitlist to become an early access user 🙂&lt;/p&gt;

&lt;p&gt;Other alternatives are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://timer.mob.sh" rel="noopener noreferrer"&gt;http://timer.mob.sh&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://remotemob.io" rel="noopener noreferrer"&gt;http://remotemob.io&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;and many more..&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  5. Time for the git handover
&lt;/h2&gt;

&lt;p&gt;When the time is up for the current driver, it’s time to handover to next driver.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;First add all changes in the repo:&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 add .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Then commit the changes:&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 commit -m wip
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The reason we set the message to wip, is to make the handover to the next driver as fast and smooth as possible.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The driver then pushes the changes:&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 push origin wip
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Next driver
&lt;/h2&gt;

&lt;p&gt;Now the next driver can safely continue. The only thing the new driver needs do to is:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;and then follow steps &lt;strong&gt;4&lt;/strong&gt; and &lt;strong&gt;5&lt;/strong&gt;. And then you just repeat!&lt;/p&gt;

&lt;h2&gt;
  
  
  Finish up
&lt;/h2&gt;

&lt;p&gt;When the mob session is happy with the code and wants to deliver it, I recommend squashing all the commits into sane pieces and write good commits messages describing the changes.&lt;/p&gt;

&lt;p&gt;This step should also be done together in as many rotations that is needed to create a git artifact that fulfills your requirements.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In my team we usually do something like 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 rebase -i origin/main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This opens an interactive editor (usually vim) where you can decide what to do with each commit:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pick abc1234 wip 
pick def5678 wip
pick ghi9012 wip
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On the first commit change &lt;code&gt;pick&lt;/code&gt; to &lt;code&gt;r&lt;/code&gt; and for the other commits change them into &lt;code&gt;f&lt;/code&gt; like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;r abc1234 wip 
f def5678 wip
f ghi9012 wip
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will let you rewrite the first commit’s message into something better and the other commits will be squash into the first commit, removing their messages.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://cbea.ms/git-commit/" rel="noopener noreferrer"&gt;Read this article to learn how to write great commit messages&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When you are happy with your new commit messages, force push the wip branch by:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git push —force origin wip
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then you are done, now you can merge the wip branch into main or open a PR/MR if that is needed in your process 🎉&lt;/p&gt;

&lt;p&gt;&lt;a href="https://blog.dskeppstedt.se/2024/11/13/how-to-do-handover-with-git-during-remote-mob-programming/" rel="noopener noreferrer"&gt;Original post&lt;/a&gt;&lt;/p&gt;

</description>
      <category>softwareteaming</category>
      <category>remote</category>
      <category>mobprogramming</category>
      <category>git</category>
    </item>
  </channel>
</rss>
