<?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: Sankeeth Sriranganathan </title>
    <description>The latest articles on DEV Community by Sankeeth Sriranganathan  (@sankeeth).</description>
    <link>https://dev.to/sankeeth</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%2F371012%2F300a67af-4006-4639-a6cf-43d91b150f74.jpg</url>
      <title>DEV Community: Sankeeth Sriranganathan </title>
      <link>https://dev.to/sankeeth</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sankeeth"/>
    <language>en</language>
    <item>
      <title>How to undo a git push</title>
      <dc:creator>Sankeeth Sriranganathan </dc:creator>
      <pubDate>Wed, 06 Mar 2024 20:10:25 +0000</pubDate>
      <link>https://dev.to/sankeeth/how-to-undo-a-git-push-7m6</link>
      <guid>https://dev.to/sankeeth/how-to-undo-a-git-push-7m6</guid>
      <description>&lt;p&gt;Programmers, even the best, can make mistakes. They might upload unfinished code online by accident, to the wrong place, or even share private info.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mistake made:&lt;/strong&gt; Pushed unwanted code online&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt; Use the &lt;code&gt;git reset&lt;/code&gt; command to remove the unwanted changes&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Use &lt;code&gt;git log&lt;/code&gt; to view your commit history and find the bad commit (like a rewind button for your code history).&lt;/li&gt;
&lt;li&gt;Run &lt;code&gt;git reset --soft &amp;lt;commit-hash&amp;gt;&lt;/code&gt; to point your branch back to a specific commit.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Two ways to "undo" a pushed commit:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;git reset --soft&lt;/code&gt;&lt;strong&gt;:&lt;/strong&gt; Keeps your changes and adds them to be committed later.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git reset --hard&lt;/code&gt;&lt;strong&gt;:&lt;/strong&gt; Completely removes the changes from your code.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Pushing the fix (optional):&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;After "undoing" the mistake, you can push the changes again using &lt;code&gt;git push --hard&lt;/code&gt;. &lt;strong&gt;Be careful!&lt;/strong&gt; This rewrites history online, so only do this if everyone agrees.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
