<?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: Umesh Sharma</title>
    <description>The latest articles on DEV Community by Umesh Sharma (@omesha).</description>
    <link>https://dev.to/omesha</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%2F968412%2F6ebd1208-167d-40b7-9625-a47753c4d49f.png</url>
      <title>DEV Community: Umesh Sharma</title>
      <link>https://dev.to/omesha</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/omesha"/>
    <language>en</language>
    <item>
      <title>Solving the Error - "fatal: refusing to merge unrelated histories"</title>
      <dc:creator>Umesh Sharma</dc:creator>
      <pubDate>Sun, 20 Jul 2025 06:48:22 +0000</pubDate>
      <link>https://dev.to/omesha/solving-the-error-fatal-refusing-to-merge-unrelated-histories-491h</link>
      <guid>https://dev.to/omesha/solving-the-error-fatal-refusing-to-merge-unrelated-histories-491h</guid>
      <description>&lt;p&gt;This is an error that I encountered while I was trying to merge the two branches &lt;em&gt;main&lt;/em&gt; and &lt;em&gt;master&lt;/em&gt;. &lt;br&gt;
So what happened, and why did this message appear, and how did I resolve the issue? &lt;/p&gt;
&lt;h2&gt;
  
  
  Let's understand what happened-
&lt;/h2&gt;

&lt;p&gt;I created a repository on GitHub with a README.md file for my project. And in my local machine, I created a project which was independent of my GitHub repository, and started committing to that independent repository locally. &lt;/p&gt;

&lt;p&gt;After adding all the commits to my local repository, I wanted to push the code to the repo on GitHub, which had the README.md file. I added the remote repo by using the command,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git remote add &amp;lt;remote-name&amp;gt; &amp;lt;remote-url&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, in order to push the commit, I had to pull the GitHub repo (that I created earlier), which had the README.md file in it, using the command,&lt;br&gt;
&lt;code&gt;&lt;br&gt;
git pull origin main&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
After pulling the file, I had to make that ultimate push to the repo, where I encountered the Error&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%2Fpgu4ekgzklys2svbwnkl.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%2Fpgu4ekgzklys2svbwnkl.png" alt="fatal: unrelated histories error" width="616" height="33"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In simple words, what I did was I initialized a local repository, made some commits to it, and later added a remote that already contained different commits.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;Why did this Error occur? let's understand it -&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;This Error occurred when I tried to merge two repositories( local and remote) that do not share any common history. It likely occurred while interacting with the remote repo when I tried to &lt;code&gt;git pull&lt;/code&gt;, &lt;code&gt;git push&lt;/code&gt;, and even &lt;code&gt;git merge&lt;/code&gt;.&lt;br&gt;
Git was not able to find the shared base to apply and combine changes. So, it refused to merge by default as a safety measure, by throwing an Error.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;So Lastly, How did I fix the Error&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;As I really wanted to combine these repositories, I used a git command to allow the merge with a git option &lt;code&gt;--allow-unrelated-histories&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git merge origin main &lt;span class="nt"&gt;--allow-unrelated-histories&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and resolved the merge conflicts that came my way. While running the above command, you will be redirected to the Vim editor. Don't worry if you don't understand it, just follow the brief guide below, and you will be good to go.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/omesha/navigating-vim-as-a-beginner-4n1f"&gt;Navigating Vim Guide&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After saving and exiting the Vim, you just have to push the commit to the branch &lt;br&gt;
&lt;code&gt;git push origin main&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: Only use this flag if you are certain that the repositories or branches are meant to be combined, as merging unrelated histories can lead to a complicated commit graph if not handled carefully.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A small tip if you are working with a team:&lt;/strong&gt;&lt;br&gt;
Always verify with your team or repository owner before merging unrelated histories to avoid unintentional conflicts or messy project history.&lt;/p&gt;

&lt;p&gt;With that, we can solve this error. Hope this helps you.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Navigating Vim as a Beginner</title>
      <dc:creator>Umesh Sharma</dc:creator>
      <pubDate>Sun, 20 Jul 2025 06:39:10 +0000</pubDate>
      <link>https://dev.to/omesha/navigating-vim-as-a-beginner-4n1f</link>
      <guid>https://dev.to/omesha/navigating-vim-as-a-beginner-4n1f</guid>
      <description>&lt;p&gt;As a Beginner, the word Vim might sound scary in the tech world, but hey, I am here to rescue. Below is the quick guide for navigating the scary Vim world. Let's get started.&lt;/p&gt;

&lt;h2&gt;
  
  
  *&lt;em&gt;Creating our first file using Vim *&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;Go to your &lt;code&gt;Bash&lt;/code&gt; terminal and run the command below to create a &lt;code&gt;newfile&lt;/code&gt;&lt;br&gt;
&lt;code&gt;vim newfile.txt&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;It will open an interface like this&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%2Ffuq1odno9ys6zk7yy8nw.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%2Ffuq1odno9ys6zk7yy8nw.png" alt="Vim Interface" width="800" height="251"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Vim has different modes, with Normal mode and Insert mode being the most important. Normal mode is used for navigation and commands, while  Insert mode is used for editing text.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Let's see how we can switch between different modes&lt;/strong&gt;-
&lt;/h2&gt;

&lt;p&gt;You can press &lt;code&gt;i&lt;/code&gt; key on your keyboard to go into the Insert mode where we can edit the text. To return to Normal mode, we can click the &lt;code&gt;Esc&lt;/code&gt; key.&lt;/p&gt;

&lt;h2&gt;
  
  
  Editing, saving files, and exiting the Vim environment-
&lt;/h2&gt;

&lt;p&gt;So, previously we have created the file &lt;code&gt;newtext.txt&lt;/code&gt;, now we are going to edit the file. &lt;br&gt;
Press the &lt;code&gt;i&lt;/code&gt; key (yes, on your keyboard) to enter the Insert mode. Enter the text you want that file to contain. You can use the arrow keys &lt;code&gt;(↑ ↓ ← →)&lt;/code&gt; to move around the editor.&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%2F8ezwmgnrluaf6yy19saa.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%2F8ezwmgnrluaf6yy19saa.png" alt="Inset Mode in Vim" width="800" height="246"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;If you are not able to edit the text, check if you are in &lt;code&gt;Insert mode&lt;/code&gt; by looking at the bottom of your editor.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;After entering the text, we got to save the file. Press the &lt;code&gt;Esc&lt;/code&gt; key to return to the &lt;code&gt;Normal mode&lt;/code&gt;. When you are in Normal mode, type the &lt;code&gt;:w&lt;/code&gt; command in your editor to save the file.&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%2F7aflrbso2yzwqgeav4um.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%2F7aflrbso2yzwqgeav4um.png" alt="Saving the text in Vim Editor" width="783" height="348"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Lastly, we need to exit our Vim environment, type the &lt;code&gt;:q&lt;/code&gt; command to exit.&lt;/p&gt;

&lt;p&gt;If you want to save and quit the editor, just type &lt;code&gt;:wq&lt;/code&gt; or &lt;code&gt;:x&lt;/code&gt;, and if you want to quit without saving, you can type &lt;code&gt;:q!&lt;/code&gt; in Normal Mode.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Dealing with Git commit message with the following steps&lt;/strong&gt;
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Press &lt;code&gt;i&lt;/code&gt; to ensure you are in Insert mode and enter the commit message.&lt;/li&gt;
&lt;li&gt;Then, press the &lt;code&gt;Esc&lt;/code&gt; key to make sure you are in Normal mode.&lt;/li&gt;
&lt;li&gt;Type &lt;code&gt;:wq&lt;/code&gt; and press &lt;code&gt;Enter&lt;/code&gt; to save the message and exit.&lt;/li&gt;
&lt;li&gt;If you want to abort the merge, type &lt;code&gt;:ql!&lt;/code&gt; then &lt;code&gt;Enter&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Command Table&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%2F9j1av7lxq6lt8n7rkdve.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%2F9j1av7lxq6lt8n7rkdve.png" alt="Vim Command Table" width="800" height="406"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So this is a quick way to create, edit, navigate, save, and exit the almighty Vim. Hope this guide helps you.&lt;/p&gt;

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