<?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: Studio Smolthing</title>
    <description>The latest articles on DEV Community by Studio Smolthing (@studiosmolthing).</description>
    <link>https://dev.to/studiosmolthing</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%2F2407885%2F60ff5bca-b1e8-40a2-a2fa-cfb7febc6618.png</url>
      <title>DEV Community: Studio Smolthing</title>
      <link>https://dev.to/studiosmolthing</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/studiosmolthing"/>
    <language>en</language>
    <item>
      <title>How I Fixed My Messed-Up Pull Request</title>
      <dc:creator>Studio Smolthing</dc:creator>
      <pubDate>Sat, 28 Dec 2024 03:16:14 +0000</pubDate>
      <link>https://dev.to/studiosmolthing/how-i-fixed-my-messed-up-pull-request-k7l</link>
      <guid>https://dev.to/studiosmolthing/how-i-fixed-my-messed-up-pull-request-k7l</guid>
      <description>&lt;p&gt;If you’ve ever worked on a large project, chances are you’ve encountered a pull request (PR) disaster. Here's how I royally messed up a PR—and how Git commands saved my ass.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Disaster
&lt;/h2&gt;

&lt;p&gt;I started by branching out changes from two unmerged PRs, creating a new "combined" branch (PR 3) to merge the changes from PR 1 and PR 2.&lt;/p&gt;

&lt;p&gt;Everything seemed fine until I noticed PR 3 was st&lt;br&gt;
ill showing changes from one of the unmerged PRs. Thinking a rebase from PR 2 would fix it, I went ahead confidently.&lt;/p&gt;
&lt;h3&gt;
  
  
  Spoiler: I was wrong.
&lt;/h3&gt;

&lt;p&gt;The rebase changed the base branch of PR 3 to PR 2, exposing all changes from PR 1.&lt;br&gt;
Trying to fix this, I thought I could simply change the base branch on GitHub.&lt;/p&gt;
&lt;h3&gt;
  
  
  Salt in the wound: I selected the wrong branch in GitHub’s dropdown.
&lt;/h3&gt;

&lt;p&gt;actual:&lt;br&gt;
long-description-combine-a-deploy&lt;br&gt;
long-description-combine-a&lt;/p&gt;

&lt;p&gt;irl: &lt;br&gt;
long-description-combine-..&lt;br&gt;
long-description-combine-..&lt;/p&gt;

&lt;p&gt;GitHub instantly closed my PR because the content didn’t match.&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%2Fsjx57uj9n3iqv1ft16im.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%2Fsjx57uj9n3iqv1ft16im.png" alt="cute drawing of prs" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thankfully, I had PR 3 branch stored in another backup repo. I forced-pushed a new combine PR (PR 1 and PR 2) to PR 3, thinking I could reused my branch. But when I double-checked, the backup branch was missing my latest commit.&lt;/p&gt;

&lt;p&gt;I’d lost my work, and my commit was nowhere to be found. (screaming into a pillow)&lt;/p&gt;
&lt;h2&gt;
  
  
  The Recovery Plan
&lt;/h2&gt;

&lt;p&gt;Here’s how I find the missing commit hash using git reflog:&lt;br&gt;
&lt;/p&gt;

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

...
c3d4f5b (HEAD -&amp;gt; feature) HEAD@{0}: commit: My precious changes
a1b2c3d HEAD@{1}: part of pr3 commit
9e8f7a6 HEAD@{2}: part of pr3 commit
...

git reset HEAD@{0}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  git reflog
&lt;/h3&gt;

&lt;p&gt;Git keeps track of updates to the tip of branches using a mechanism called reference logs, or "reflogs." &lt;code&gt;git reflog&lt;/code&gt; is a Git command that tracks updates to your repository’s HEAD. It shows a history of all actions, like commits, rebases, resets, or checkouts—even if those changes aren’t part of the visible branch history.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why is it useful?
&lt;/h3&gt;

&lt;p&gt;If you lose a commit or accidentally reset your branch, git reflog helps you find and recover the missing work by providing the commit hashes of past actions.&lt;/p&gt;

&lt;p&gt;All was well again.&lt;/p&gt;

&lt;h3&gt;
  
  
  Saviour article
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://medium.com/@krokowski.dx/how-to-undo-your-git-failure-b76e31ecac74" rel="noopener noreferrer"&gt;https://medium.com/@krokowski.dx/how-to-undo-your-git-failure-b76e31ecac74&lt;/a&gt;&lt;/p&gt;

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