<?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: Aanshik Sharma</title>
    <description>The latest articles on DEV Community by Aanshik Sharma (@aanshik_sharma_26dd97ab33).</description>
    <link>https://dev.to/aanshik_sharma_26dd97ab33</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%2F3977606%2Fffa7648a-dc26-46d3-87ba-70ede577bf59.jpg</url>
      <title>DEV Community: Aanshik Sharma</title>
      <link>https://dev.to/aanshik_sharma_26dd97ab33</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aanshik_sharma_26dd97ab33"/>
    <language>en</language>
    <item>
      <title>How to fix your last commit without creating a new one...</title>
      <dc:creator>Aanshik Sharma</dc:creator>
      <pubDate>Wed, 10 Jun 2026 14:30:00 +0000</pubDate>
      <link>https://dev.to/aanshik_sharma_26dd97ab33/how-to-fix-your-last-commit-without-creating-a-new-one-5232</link>
      <guid>https://dev.to/aanshik_sharma_26dd97ab33/how-to-fix-your-last-commit-without-creating-a-new-one-5232</guid>
      <description>&lt;p&gt;One habit quietly polluted my Git history for months. Sometimes when we make a commit and realize that a feature has been left uncommitted, we just create a new commit with a commit message close to “Project feature update final final v2”.&lt;/p&gt;

&lt;p&gt;There is actually nothing wrong with it except the fact that it really builds up the commit history with utter nonsense commit messages. This, feeds ambiguity and ambiguity kills systems.&lt;/p&gt;

&lt;p&gt;However, this can be fixed by a simple command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git commit &lt;span class="nt"&gt;--amend&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;--amend&lt;/code&gt; flag replaces the previous commit with a new version of that commit. To you it looks like the old commit was edited, but Git actually rewrites that part of history.&lt;/p&gt;

&lt;p&gt;It can be thought of as replacing the previous commit with a new one; all the changes from the previous commit persist while the new changes also appear in the HEAD node, without clogging up the commit history.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Edit the last commit message
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git commit &lt;span class="nt"&gt;--amend&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Opens your default editor to modify the message.&lt;br&gt;
Or you can do it directly without opening an editor:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git commit &lt;span class="nt"&gt;--amend&lt;/span&gt; &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"Commit Message"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Change Author or Commit Date
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git commit &lt;span class="nt"&gt;--amend&lt;/span&gt; &lt;span class="nt"&gt;--author&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"Jane Doe &amp;lt;janedoe@gmail.com&amp;gt;"&lt;/span&gt;
git commit &lt;span class="nt"&gt;--amend&lt;/span&gt; &lt;span class="nt"&gt;--date&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"2026-06-10T12:00:00"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Amend a commit without changing the commit message
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git add forgotten-file.js
git commit &lt;span class="nt"&gt;--amend&lt;/span&gt; &lt;span class="nt"&gt;--no-edit&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the commit has not been pushed yet, the above commands are usually all you need. But if the commit was pushed, two cases emerge:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;You are working alone or on a private branch&lt;/p&gt;

&lt;p&gt;In this case, you can just push the amended commit using&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git push &lt;span class="nt"&gt;--force-with-lease&lt;/span&gt; origin &amp;lt;branch-name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;This safely overwrites the remote branch only if no one else has pushed changes since your last fetch.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Always use &lt;code&gt;--force-with-lease&lt;/code&gt; instead of &lt;code&gt;--force&lt;/code&gt; to prevent accidentally deleting a teammate’s work if they pushed while you were amending.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You are working on a shared branch with your teammates&lt;/p&gt;

&lt;p&gt;If the commit has already been pushed to a shared branch, avoid amending it unless everyone collaborating on the branch understands that history is being rewritten. In most team environments, creating a follow-up commit is usually safer than force-pushing rewritten history.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>beginners</category>
      <category>git</category>
      <category>productivity</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Hello World</title>
      <dc:creator>Aanshik Sharma</dc:creator>
      <pubDate>Wed, 10 Jun 2026 13:34:06 +0000</pubDate>
      <link>https://dev.to/aanshik_sharma_26dd97ab33/hello-world-1008</link>
      <guid>https://dev.to/aanshik_sharma_26dd97ab33/hello-world-1008</guid>
      <description>&lt;p&gt;Hi, I'm Aanshik.&lt;/p&gt;

&lt;p&gt;I've always found myself chasing questions.&lt;/p&gt;

&lt;p&gt;Sometimes those questions are related to software. Sometimes they're about how computers work under the hood. Sometimes they're completely unrelated to anything I need for a project, an exam, or a career.&lt;/p&gt;

&lt;p&gt;I simply enjoy understanding things.&lt;/p&gt;

&lt;p&gt;Over the years, I've learned a lot of interesting concepts, solved a lot of frustrating problems, and discovered plenty of things that made me stop and think, "I wish I had known this earlier."&lt;/p&gt;

&lt;p&gt;The problem is that these lessons tend to disappear. We learn something, use it once, and move on to the next challenge.&lt;/p&gt;

&lt;p&gt;This blog is my attempt to change that.&lt;/p&gt;

&lt;p&gt;Rather than letting ideas fade away, I want to document them. Some posts may be technical. Others may be observations, experiments, lessons, mistakes, or rabbit holes I happened to fall into while trying to understand something.&lt;/p&gt;

&lt;p&gt;I don't know exactly what this blog will become, and that's part of the reason I'm excited to start it.&lt;/p&gt;

&lt;p&gt;What I do know is that I'm curious, and curiosity has led me to some interesting places so far.&lt;/p&gt;

&lt;p&gt;This blog is simply a record of that journey.&lt;/p&gt;

&lt;p&gt;Let's see where it goes.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>devjournal</category>
      <category>learning</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
