<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Krishna]]></title><description><![CDATA[Krishna]]></description><link>https://blog.krishnakantverma.com</link><image><url>https://cdn.hashnode.com/res/hashnode/image/upload/v1757764196132/3df9cf11-58d3-49fa-9311-46bb2c85c80a.png</url><title>Krishna</title><link>https://blog.krishnakantverma.com</link></image><generator>RSS for Node</generator><lastBuildDate>Mon, 27 Apr 2026 15:29:54 GMT</lastBuildDate><atom:link href="https://blog.krishnakantverma.com/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Top Must-Know Git Commands for Everyone]]></title><description><![CDATA[Starting your coding journey is exciting, but it comes with a common question:
"How do I manage all my code changes?"
You quickly discover Git and GitHub, learn the basic commands, and start feeling in control. But then comes the moment you need to s...]]></description><link>https://blog.krishnakantverma.com/top-must-know-git-commands-for-everyone</link><guid isPermaLink="true">https://blog.krishnakantverma.com/top-must-know-git-commands-for-everyone</guid><category><![CDATA[must-know-git-commands]]></category><category><![CDATA[git commands for beginners]]></category><category><![CDATA[Git Commands]]></category><category><![CDATA[github-commands]]></category><category><![CDATA[github commands for beginners]]></category><dc:creator><![CDATA[Krishna]]></dc:creator><pubDate>Mon, 22 Sep 2025 11:59:37 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1758542240570/72fbe74e-d8aa-43c0-a76b-6b94969c6608.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Starting your coding journey is exciting, but it comes with a common question:</p>
<p><strong><em>"How do I manage all my code changes?"</em></strong></p>
<p>You quickly discover <strong>Git</strong> and <strong>GitHub</strong>, learn the basic commands, and start feeling in control. But then comes the moment you need to set up a new project or fix a mistake, and suddenly, the basics don't feel like enough.</p>
<p>If that sounds familiar, so do I, means I was in your shoes until I don’t create a cheat sheet for myself.</p>
<p>In this guide I will give you the essential git commands you need to confidently manage your projects from start to finish.</p>
<p><strong><em>Spoiler: The commands below are for daily use and managing repositories, mainly for local development. They are just the tip of the iceberg.</em></strong></p>
<p>Whether you're new to coding or an experienced developer, Git is a must-have tool for managing your projects. It's a strong version control system with many commands, and figuring out when to use them can be confusing.</p>
<h1 id="heading-why-git">Why Git?</h1>
<p>There are many tools available as alternatives to Git and GitHub, like <strong>Bitbucket</strong>, <strong>SVN</strong>, <strong>SourceForge</strong>, <strong>AWS</strong> <strong>CodeCommit</strong>, and <strong>Gitea</strong>. I chose Git because it was the first one I learned. Before that, I was using an FTP client(<em>Wondering why and how? I'll write about it in my personal blog!</em> ).</p>
<p>Right now, we'll explore Git, and this guide provides a simple, practical list of the Git commands you'll use the most. Let's get started!</p>
<h2 id="heading-initial-setup-amp-config">Initial Setup &amp; Config</h2>
<p>First things first, let's create your Git environment on local machine for coding.</p>
<blockquote>
<p><code>git init</code></p>
</blockquote>
<p>This creates a new, empty Git repository in your current working directory on local machine. This is the starting point for any new project.</p>
<p>In the image below, you can see that the PythonPlayBook directory contains only one file named <strong>printer.py</strong>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1758464244406/9eb426cf-9aa6-402a-800f-bd2bd0246994.png" alt class="image--center mx-auto" /></p>
<p>To save this on my GitHub account, I need to run <code>git init</code>, which gives the response below.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1758464405900/9577082d-cb1c-4fa3-b001-9a787fbf873b.png" alt class="image--center mx-auto" /></p>
<blockquote>
<p><code>git config --list</code></p>
</blockquote>
<p>To view Git configuration settings, including your username and email for the current repository</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1758464537509/82519427-7dbe-43a5-ac7c-9642bf9f972e.png" alt class="image--center mx-auto" /></p>
<blockquote>
<p><code>git config user.name "Your Name"</code> or <code>git config user.email "youremail@example.com"</code></p>
</blockquote>
<p>Want to set any specific user for this repository, use these command</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1758464902465/b5b313f2-b100-4461-b4bf-eaba69f8e889.png" alt class="image--center mx-auto" /></p>
<p>also If want to check which user is already mapped to the repository use the same command without adding <code>“Value“</code></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1758534387012/efde5b57-a6d9-4622-9745-473898904c8e.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-ready-to-play">Ready To Play</h2>
<p>These commands will save your everyday work that you done.</p>
<blockquote>
<p><code>git status</code></p>
</blockquote>
<p>This command displays the status of files in your working directory and staging area, indicating which files are <strong>modified</strong>, <strong>staged for the next commit</strong>, or <strong>untracked</strong>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1758534552702/3d2e6422-a8a6-4c87-8a09-93f93ee86b73.png" alt class="image--center mx-auto" /></p>
<blockquote>
<p><code>git add .</code> or <code>git add &lt;file-name&gt;</code></p>
</blockquote>
<p>This command adds files to the <strong>staging area</strong>, preparing them for the next commit. Think of the staging area as a "waiting room" for your changes in file.</p>
<p>If we want to push all files in staging area we can use <code>git add .</code> in which (<code>.</code>) is for select all files</p>
<p>but If you want to add a specific file you can go with the <code>git add &lt;file-name&gt;</code></p>
<p>After adding files, you can check the status again</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1758535341278/2a8c863e-3c04-4282-85e3-6360f764b262.png" alt class="image--center mx-auto" /></p>
<blockquote>
<p><code>git commit -m "Your descriptive message"</code></p>
</blockquote>
<p>Now it's time to save the staged changes to your project's history. The <code>-m</code> flag lets you add a message describing what you changed.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1758535513762/515104be-614b-46c2-893e-d5d0a376a3e8.png" alt class="image--center mx-auto" /></p>
<blockquote>
<p><code>git log</code></p>
</blockquote>
<p>Displays the commit history for the current branch, showing who made changes, when they did, and the commit message.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1758536117992/e3156603-986b-4d30-9ba3-3f7f8662b41e.png" alt class="image--center mx-auto" /></p>
<div data-node-type="callout">
<div data-node-type="callout-emoji">✍</div>
<div data-node-type="callout-text">To see changes made in a specific commit, use <code>git show &lt;commit-hash&gt;</code>.</div>
</div>

<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1758536353167/ab3d6a96-56ce-487d-8bce-dc4175f0f5b1.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-undoing-changes-safely">Undoing Changes (Safely!)</h2>
<p>Made a mistake? No problem. These commands are your safety net.</p>
<blockquote>
<p><code>git restore --staged &lt;file&gt;</code></p>
</blockquote>
<p>Removes a file from the staging area but <strong>keeps the changes</strong> in your working directory. This is perfect for "un-adding" a file you staged by accident.</p>
<blockquote>
<p><code>git reset --soft HEAD~1</code></p>
</blockquote>
<p>Undoes the last commit but keeps all changes in the staging area. It's like you've hit "undo" on the commit itself, but not on your work, also remove the log entries.</p>
<blockquote>
<p><code>git reset --hard HEAD~1</code></p>
</blockquote>
<p>This will also undo the last commit but it will <strong>permanently deletes</strong> all associated changes from your working directory, ⚠️ <strong>Use with extreme caution!</strong></p>
<blockquote>
<p><code>git revert &lt;commit-hash&gt;</code></p>
</blockquote>
<p>Creates a new commit to safely reverse changes from a previous commit without removing log entries, making it easy to track changes.</p>
<h2 id="heading-working-with-remote-repositories">Working with Remote Repositories</h2>
<p>Back up your code on platforms like GitHub.</p>
<blockquote>
<p><code>git remote -v</code></p>
</blockquote>
<p>Lists all the remote repositories connected to your local one, displaying their URLs, but shows nothing for a newly created local repository.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1758538714888/10d14444-4804-43f4-993a-ca478fd961a6.png" alt class="image--center mx-auto" /></p>
<blockquote>
<p><code>git remote remove origin</code></p>
</blockquote>
<p>Let say you have multiple git hub account now you have to disconnects the remote repository named <code>origin</code> from your local project.</p>
<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text">Want to Know, how to manage multiple git hub accounts? <a target="_self" href="https://krishnakant.hashnode.dev/effortlessly-switch-between-github-accounts-a-guide-for-developers">#MultipleGithubAccountSetUP</a></div>
</div>

<blockquote>
<p><code>git remote add origin &lt;remote-repository-url&gt;</code></p>
</blockquote>
<p>This command will connect your local repository to a remote one.</p>
<p>If you don't know how to create a remote repository, log into your GitHub account, find the green <strong>New</strong> button at the top left, or open <a target="_blank" href="https://github.com/new">https://github.com/new</a> in a new tab.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1758537925253/6cf4f244-9722-4c49-9c84-7a93ccead7cf.png" alt /></p>
<p>After that, you'll see the page below. Fill in the fields, then hit the create repository button.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1758538001782/693e848e-89d7-480d-9e41-07483fbe12dd.png" alt /></p>
<p>copy the marked URL, that is your <strong><em>remote-repository-url</em></strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1758538157741/c465e0e8-d227-40f8-a7bb-77660aa0497f.png" alt /></p>
<blockquote>
<p><code>git push -u origin main</code></p>
</blockquote>
<p>Finally, uploads your committed changes from your local <code>main</code> branch to the remote repository.</p>
<h2 id="heading-stashing-saving-changes-for-later">Stashing: Saving Changes for Later</h2>
<p>Need to switch branches but aren't ready to commit? <code>git stash</code> is your best friend.</p>
<blockquote>
<p><code>git stash</code> or <code>git stash push -m "A message"</code></p>
</blockquote>
<p>Temporarily saves your uncommitted changes (both staged and un-staged) so you can get a clean working directory.</p>
<ul>
<li><p><code>git stash</code> saves all your uncommitted changes (both staged and unstaged) in a "stash" and reverts your working directory to the last commit (<code>HEAD</code>).</p>
</li>
<li><p><code>git stash push -m "A message"</code> lets you stash only specific files by providing a file path.</p>
<ul>
<li><code>git stash push -m "Stashing just the CSS changes" -- src/styles/main.css</code></li>
</ul>
</li>
</ul>
<blockquote>
<p><code>git stash list</code></p>
</blockquote>
<p>Displays a list of all your stashed changes.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1758540138381/124a52ba-1f70-4a72-8ed8-dca768b4042a.png" alt class="image--center mx-auto" /></p>
<blockquote>
<p><code>git stash apply</code> or <code>git stash apply stash@{&lt;index&gt;}</code></p>
</blockquote>
<p>Applies the changes from your latest or specific stash back to your working directory while keeping a copy of the stash.</p>
<blockquote>
<p><code>git stash pop</code> or <code>git stash apply stash@{&lt;index&gt;}</code></p>
</blockquote>
<p><strong>applies the changes</strong> from latest or specific stash and then <strong>removes the stash</strong> from your list.</p>
<blockquote>
<p><code>git stash drop</code> or <code>git stash apply stash@{&lt;index&gt;}</code></p>
</blockquote>
<p><strong>Deletes</strong> the latest or specific stash from your list without applying its changes.</p>
<blockquote>
<p><code>git stash show</code> or <code>git stash show stash@{&lt;index&gt;}</code></p>
</blockquote>
<p>Shows a <strong>summary</strong> of the latest or specific stash.</p>
<blockquote>
<p><code>git stash show -p</code> or <code>git stash show -p stash@{&lt;index&gt;}</code></p>
</blockquote>
<p>Shows the <strong>full diff</strong> of the latest or specific stash.</p>
<blockquote>
<p><code>git stash clear</code></p>
</blockquote>
<p>Deletes all of your stashed changes. ⚠️ <strong>This cannot be undone, so use it carefully!</strong></p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Git is a crucial tool for developers, providing strong version control to manage code effectively. By learning key commands like <code>git init</code>, <code>git clone</code>, <code>git add</code>, <code>git commit</code>, <code>git status</code>, <code>git push</code>, <code>git pull</code>, and <code>git branch</code>, you can start repositories, track changes, save work, check repository status, share and integrate updates, and manage branches. Mastering these commands improves workflow, collaboration, and project integrity.</p>
<p>That's all from my side. Thank you for your time, and I look forward to seeing what you'll achieve!</p>
<p>Don’t forget to comment (“I was here”).</p>
]]></content:encoded></item><item><title><![CDATA[Effortlessly Switch Between GitHub Accounts: A Guide for Developers]]></title><description><![CDATA[Are you a developer who finds yourself constantly switching between your work and personal GitHub accounts?
Do you find yourself triple-checking email address of your latest commit?
It can be really frustrating to keep your professional and personal ...]]></description><link>https://blog.krishnakantverma.com/effortlessly-switch-between-github-accounts-a-guide-for-developers</link><guid isPermaLink="true">https://blog.krishnakantverma.com/effortlessly-switch-between-github-accounts-a-guide-for-developers</guid><category><![CDATA[github-multiple-account]]></category><category><![CDATA[GitHub]]></category><category><![CDATA[GitHub account]]></category><dc:creator><![CDATA[Krishna]]></dc:creator><pubDate>Sat, 13 Sep 2025 11:39:35 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1757763394787/528cc5fe-3bec-442c-9e73-66e682448981.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><strong><em>Are you a developer who finds yourself constantly switching between your work and personal GitHub accounts?</em></strong></p>
<p><strong><em>Do you find yourself triple-checking email address of your latest commit?</em></strong></p>
<p>It can be really frustrating to keep your professional and personal code repositories separate, especially when you use the same machine for both work and personal tasks.</p>
<p>You're not alone, my friend! I was in the same situation and found a way to manage multiple GitHub accounts on one machine. I use Ubuntu, so I know it works there, but you can also try it on mac Os and Windows. Let me know in the comments if it works for you or not, so we can figure it out together.</p>
<p>I assume you already have more than one GitHub account and are facing this situation, which is why you're here looking for a solution. For those new to this, let me explain:</p>
<h2 id="heading-why-we-need-separate-git-hub-accounts">Why we need Separate Git hub accounts?</h2>
<p>Before we dive into how, let's quickly look at <em>why</em> this setup is so valuable.</p>
<ul>
<li><p><strong>A Clean Divide: Work vs. Personal Projects</strong> Keep your professional work and personal projects separate. This helps to maintain clarity, especially when dealing with different project requirements, licenses, or team policies.</p>
</li>
<li><p><strong>No More Accidental Commits</strong>: Ensure that every commit you make is correctly attributed to the right GitHub profile. No more accidental commits to your personal account from a work project, or vice-versa!</p>
</li>
<li><p><strong>Better Security</strong>: Using different SSH keys for each account adds extra security. If one key gets compromised, your other accounts stay safe. It's also generally a better practice than just using HTTPS credentials.</p>
</li>
</ul>
<h2 id="heading-follow-these-steps-with-me">Follow these steps with me:</h2>
<h3 id="heading-step-1-generate-a-new-ssh-key-for-each-account">Step 1: Generate a New SSH Key for Each Account</h3>
<ol>
<li><p><strong>Open your terminal</strong> (Git Bash on Windows, Terminal on macOS/Linux).</p>
</li>
<li><p><strong>Generate a new SSH key</strong> using the <code>ssh-keygen</code> command. Crucially, you'll specify a unique filename for each key. For example, for your personal account:</p>
</li>
</ol>
<pre><code class="lang-plaintext">// Account 1
ssh-keygen -t ed25519 -C "your_personal_email@gmail.com" -f ~/.ssh/id_ed25519_acc1

// Account 2
ssh-keygen -t ed25519 -C "your_work_email@gmail.com" -f ~/.ssh/id_ed25519_acc2
</code></pre>
<p>As soon as you type the above command and press enter, you'll be prompted for a passphrase. You can leave it empty if you don't want to create one. It will then ask for confirmation; just press enter.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1757752693672/770285e5-76a4-4df5-b586-7014297a0eed.png" alt="prompt message screenshot" class="image--center mx-auto" /></p>
<p><strong>Breakdown of the Command</strong></p>
<ul>
<li><p><code>ssh-keygen</code>: This is the command-line utility used for creating, managing, and converting authentication keys for SSH (Secure Shell).</p>
</li>
<li><p><code>-t ed25519</code>: The <code>-t</code> flag specifies the <strong>type of key to create</strong>. <code>ed25519</code> refers to the Ed25519 algorithm, which is a modern, highly secure, and efficient public-key signature system. It's generally preferred over older algorithms like RSA due to its performance and security benefits.</p>
</li>
<li><p><code>-C "your_work_email@gmail.com"</code>: The <code>-C</code> flag adds a <strong>comment</strong> to the key. This comment doesn't affect the key's functionality but serves as a label to help you identify the key's purpose. In this case, it's used to identify the user or the purpose of the key.</p>
</li>
<li><p><code>-f ~/.ssh/id_ed25519_acc1</code>: The <code>-f</code> flag specifies the <strong>file path and name</strong> where the key pair will be saved.</p>
<ul>
<li><p><code>~/.ssh/</code>: This is the default directory for storing SSH keys. The <code>~</code> represents the user's home directory.</p>
</li>
<li><p><code>id_ed25519_acc1</code>: This is the base filename for the key pair.</p>
<ul>
<li>The private key will be saved as <code>id_ed25519_acc1</code>, and the corresponding public key will be saved with a <code>.pub</code> extension, as <code>id_ed25519_acc1.</code><a target="_blank" href="http://prof.pub"><code>pub</code></a>.</li>
</ul>
</li>
</ul>
</li>
</ul>
<ol start="3">
<li><p><strong>Start the SSH agent</strong> in the background:</p>
<pre><code class="lang-plaintext"> eval "$(ssh-agent -s)"
</code></pre>
</li>
<li><p><strong>Add your new SSH keys to the SSH agent</strong>:</p>
<pre><code class="lang-plaintext"> ssh-add ~/.ssh/id_ed25519_acc1
 ssh-add ~/.ssh/id_ed25519_acc2
</code></pre>
</li>
</ol>
<hr />
<p><strong><em>Check if the public key exists at the location or not</em></strong> <code>ls ~/.ssh</code></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1757753441405/4286df64-676b-43dd-a7c6-094e9a1091e9.png" alt="public and private key files screenshot" /></p>
<p>If the keys don't exist, you might have missed something. Try doing <mark>Step 1</mark> again or check the file name and comments you used when creating the key.</p>
<h3 id="heading-step-2-add-the-public-ssh-keys-to-your-github-accounts">Step 2: Add the Public SSH Keys to your GitHub Accounts</h3>
<p>I assume you have your keys now, so let's inform GitHub about them.</p>
<ol>
<li><p><strong>Log in to your <em>personal</em> GitHub account</strong> in your web browser.</p>
</li>
<li><p>Go to <strong>Settings</strong> -&gt; <strong>SSH and GPG keys</strong>.</p>
</li>
<li><p>Click <strong>"New SSH key"</strong> or <strong>"Add SSH key"</strong>.</p>
</li>
<li><p>Provide a <strong>Title</strong> (“what ever you want it“) and paste the copied public key into the <strong>"Key"</strong> field.</p>
</li>
<li><p>Click <strong>"Add SSH key"</strong>.</p>
</li>
</ol>
<p><em>Oh! I didn't tell you how to copy the key, did I?</em></p>
<p>I assume you know where your public key is located, such as in <code>~/.ssh/</code>. Simply run the command below and copy the content and paste it into the <strong>"Key"</strong> field.</p>
<pre><code class="lang-plaintext">cat ~/.ssh/id_ed25519_acc1.pub
</code></pre>
<p>Boom! Your personal account SSH setup is complete. Now, do the same steps for your professional account.</p>
<p><strong>Remember:</strong> Each public key (<code>.pub</code> file) will be linked to its specific GitHub account.</p>
<h3 id="heading-step-3-create-an-ssh-config-file">Step 3: Create an SSH Config File</h3>
<p>This is where the magic happens! The <code>~/.ssh/config</code> file tells your system which SSH key to use for specific GitHub hosts.</p>
<p><strong><em>Check if the</em></strong> <code>config file</code> <strong><em>exists at the location or not</em></strong> <code>ls ~/.ssh</code></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1757755153073/5a2373f5-5ec1-444e-848f-98dc94a02af0.png" alt="config file screenshot" /></p>
<p>If you are doing this for the first time or don't have the config file, follow the steps below.</p>
<ol>
<li><p><strong>Create a</strong> <code>config</code> file without any <strong>dot (.) extension</strong> in your <code>~/.ssh/</code> directory</p>
<pre><code class="lang-plaintext"> # Below command will work for linux user
 touch ~/.ssh/config

 ## windows people, you know how to create files... Just Do It. :)
</code></pre>
</li>
<li><p><strong>Add the following configuration</strong> to the <code>config</code> file. Replace the placeholders with your actual email addresses and key filenames:</p>
<pre><code class="lang-plaintext"> # Professional Account
 Host work
   HostName github.com
   User git
   IdentityFile ~/.ssh/id_ed25519_acc2
   IdentitiesOnly yes

 # Personal Account
 Host personal
   HostName github.com
   User git
   IdentityFile ~/.ssh/id_ed25519_acc1
   IdentitiesOnly yes
</code></pre>
</li>
</ol>
<p><strong>Breakdown</strong></p>
<ul>
<li><p><strong>Host</strong> <code>work</code>: This sets up a custom name you'll use in your Git commands. You can call it anything you want, like <code>github.com-personal</code>, <code>work</code>, or <code>prof</code>.</p>
</li>
<li><p><strong>HostName</strong> <a target="_blank" href="http://github.com"><code>github.com</code></a>: This tells SSH to actually connect to the <a target="_blank" href="http://github.com"><code>github.com</code></a>.</p>
</li>
<li><p><strong>User</strong> <code>git</code>: Specifies the user for the SSH connection, which is always <code>git</code> for the GitHub.</p>
</li>
<li><p><strong>IdentityFile</strong> <code>~/.ssh/id_ed25519_acc1</code>: This is crucial – it points to the specific private key file to use for this host.</p>
</li>
<li><p><strong>IdentitiesOnly</strong> <code>yes</code>:Prevents SSH from using other keys, making sure only the specified key is used. You can skip this if you prefer.</p>
</li>
</ul>
<ol start="3">
<li><strong>Save and close</strong> the <code>config</code> file.</li>
</ol>
<h3 id="heading-step-4-set-up-git-for-each-repository">Step 4: Set Up Git for Each Repository</h3>
<h3 id="heading-the-last-step-is-to-tell-git-which-github-account-to-use-for-each-specific-repository">The last step is to tell Git which GitHub account to use for each specific repository.</h3>
<p>Before moving further, <strong>Test your SSH connections</strong> using below command:</p>
<pre><code class="lang-plaintext">ssh -T git@personal
#You should see the message: Hi your_personal_username! You've successfully authenticated...

ssh -T git@work
# You should see the message: Hi your_work_username! You've successfully authenticated...
</code></pre>
<p>If everything works as expected, we can now start configuring repositories.</p>
<ol>
<li><p><strong>Go to your repository's folder</strong> in the terminal: <code>cd path/to/your/personal-project</code></p>
</li>
<li><p><strong>Set the local Git user name and email</strong> for <em>that specific repository</em></p>
<pre><code class="lang-plaintext"> git config user.name "Your Personal Name"
 git config user.email "your_personal_email@example.com"
</code></pre>
<p> <em>Don't forget to set up your work/professional repository by following the same steps mentioned above.</em></p>
<p> <strong>Important:</strong> Notice there's no <code>--global</code> flag here. This ensures the configuration applies <em>only</em> to the current repository.</p>
</li>
</ol>
<p><strong>Update the remote URL for the repository:</strong> Now you'll need to change the remote URL of your cloned repository.</p>
<pre><code class="lang-plaintext">git remote set-url origin git@personal:username/repo-name.git
</code></pre>
<p>or you want to create new repository on local and want it push on specific git hub account</p>
<pre><code class="lang-plaintext"># Basic Step commands to create git repository
git init # create repo at local level
echo "# Repo1" &gt; README.md # create readmeFile not compulsory
git add .  # add all content in the repo
git commit -m "initial commit" 
git branch -M main # setting main as branch, else master will be default created branch

# Set github account, on which you want to create repository
git remote add origin git@work:workGithubUserName/xtrext.git 

# push the code
git push -u origin main
</code></pre>
<div data-node-type="callout">
<div data-node-type="callout-emoji">🖊</div>
<div data-node-type="callout-text">Below is the dissection of the code part used above, notice the colored part.</div>
</div>

<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1758542744617/0cc0d9ae-b2a4-43c0-8e8b-834acc19ee4c.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Congratulations! Now you know how to manage multiple GitHub accounts on one computer. By using SSH keys and setting up the <code>~/.ssh/config</code> file correctly, you can easily switch between your personal and work coding environments. This setup keeps your development workflow neat and organised.</p>
<p>No more headaches, no more accidental commits.</p>
<p>Just smooth, efficient coding across all your projects. Happy coding!</p>
<p>For more information or useful GitHub commands, please check my short note on daily GitHub commands: <a target="_blank" href="https://krishnakant.hashnode.dev/top-must-know-git-commands-for-everyone">#MustKnowGitCommands</a>.</p>
<p>Don’t forget to comment (“I was here”).</p>
]]></content:encoded></item></channel></rss>