<?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>Forem: Rahul Kumar Bharti</title>
    <description>The latest articles on Forem by Rahul Kumar Bharti (@rahulkbharti).</description>
    <link>https://forem.com/rahulkbharti</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%2F3676287%2F063785fb-ae2b-4dad-a9e8-eb60554f418e.jpg</url>
      <title>Forem: Rahul Kumar Bharti</title>
      <link>https://forem.com/rahulkbharti</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/rahulkbharti"/>
    <language>en</language>
    <item>
      <title>Stop Pushing Work Code with Your Personal Email: The Ultimate Guide to Multiple GitHub Accounts on Windows</title>
      <dc:creator>Rahul Kumar Bharti</dc:creator>
      <pubDate>Wed, 24 Dec 2025 06:24:53 +0000</pubDate>
      <link>https://forem.com/rahulkbharti/stop-pushing-work-code-with-your-personal-email-the-ultimate-guide-to-multiple-github-accounts-on-39bg</link>
      <guid>https://forem.com/rahulkbharti/stop-pushing-work-code-with-your-personal-email-the-ultimate-guide-to-multiple-github-accounts-on-39bg</guid>
      <description>&lt;p&gt;If you are like me, you probably have a personal GitHub account for your side projects and a separate professional account for your company. And if you’re working on a Windows machine using VS Code, you’ve likely hit the wall where Git doesn't know who you are.&lt;/p&gt;

&lt;p&gt;I recently spent hours struggling with this. I tried running Linux commands like eval &lt;code&gt;$(ssh-agent -s)&lt;/code&gt; in PowerShell (which didn't work), got "Permission Denied" errors, and even accidentally pushed work code using my personal email. 🤦‍♂️&lt;/p&gt;

&lt;p&gt;After figuring it out, I decided to document the exact, battle-tested method to manage multiple GitHub accounts on Windows without going crazy.&lt;/p&gt;

&lt;p&gt;Here is how to do it right.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Concept: SSH Keys &amp;amp; Aliases
&lt;/h2&gt;

&lt;p&gt;By default, Git pushes code as one global user. To switch between accounts, we need:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Two separate SSH Keys (ID cards).&lt;/li&gt;
&lt;li&gt;A Config File that tells your computer: "If I use the alias github-work, use my Work Key."&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Step 1: Generate Unique SSH Keys
&lt;/h2&gt;

&lt;p&gt;Open PowerShell and create a &lt;code&gt;.ssh&lt;/code&gt; directory if you don't have one.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;mkdir&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="bp"&gt;$HOME&lt;/span&gt;&lt;span class="nx"&gt;\.ssh&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;cd&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="bp"&gt;$HOME&lt;/span&gt;&lt;span class="nx"&gt;\.ssh&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, create two keys. Don't overwrite your existing default key (id_rsa). Give them specific names:&lt;/p&gt;

&lt;h3&gt;
  
  
  For Personal:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;ssh-keygen&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;-t&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;ed25519&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;-C&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"personal@gmail.com"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;-f&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;id_personal&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  For Work:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;ssh-keygen&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;-t&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;ed25519&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;-C&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"work@company.com"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;-f&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;id_work&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 2: The "Eval" Problem (And the Windows Solution)
&lt;/h2&gt;

&lt;p&gt;Most tutorials tell you to run &lt;code&gt;eval $(ssh-agent -s)&lt;/code&gt;. This command often fails or does nothing in Windows PowerShell.&lt;/p&gt;

&lt;p&gt;Instead of fighting with the terminal, use the native Windows Service. This is better because it persists even after you restart your computer.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open PowerShell as Administrator.&lt;/li&gt;
&lt;li&gt;Run these two commands:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c"&gt;# Set the service to run automatically&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;Get-Service&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;-Name&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;ssh-agent&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Set-Service&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;-StartupType&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;Automatic&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c"&gt;# Start the service&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;Start-Service&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;ssh-agent&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Now, add your keys (you can do this in a normal PowerShell window):
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;ssh-add&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="bp"&gt;$HOME&lt;/span&gt;&lt;span class="nx"&gt;\.ssh\id_personal&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;ssh-add&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="bp"&gt;$HOME&lt;/span&gt;&lt;span class="nx"&gt;\.ssh\id_work&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run &lt;code&gt;ssh-add -l&lt;/code&gt; to confirm both keys are loaded.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Upload Keys to GitHub
&lt;/h2&gt;

&lt;p&gt;You need to introduce yourself to GitHub.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Copy the content of your &lt;strong&gt;Personal Public Key&lt;/strong&gt; (id_personal.pub).&lt;/li&gt;
&lt;li&gt;Go to Personal GitHub &amp;gt; Settings &amp;gt; SSH Keys &amp;gt; New SSH Key and paste it.&lt;/li&gt;
&lt;li&gt;Repeat this for your Work Public Key (id_work.pub) on your Company GitHub account.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Step 4: The Magic Config File (The Router)
&lt;/h2&gt;

&lt;p&gt;This is the most important step. Create a &lt;code&gt;file&lt;/code&gt; named config (no extension) inside your &lt;code&gt;$HOME\.ssh\&lt;/code&gt; folder.&lt;/p&gt;

&lt;p&gt;Paste this configuration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
# Personal Account - Default
Host github.com
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_personal

# Work Account - The Custom Alias
Host github-work
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_work

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 5: Cloning &amp;amp; Configuring Repos
&lt;/h2&gt;

&lt;p&gt;Here is where the workflow changes slightly.&lt;br&gt;
For Personal Projects: Clone as usual: &lt;code&gt;git clone git@github.com:username/repo.git&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;For Work Projects: You must replace &lt;code&gt;github.com&lt;/code&gt; with your alias &lt;code&gt;github-work&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;git&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;clone&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;git&lt;/span&gt;&lt;span class="err"&gt;@&lt;/span&gt;&lt;span class="nx"&gt;github-work:company/repo.git&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  ⚠️ Crucial Step: Set Your Local Identity
&lt;/h3&gt;

&lt;p&gt;Once you clone the work repo, immediately run this inside the folder. If you forget this, your commits will show up as your personal user!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;git&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;config&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;user.name&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Your Work Name"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;git&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;config&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;user.email&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"work@company.com"&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Bonus: "Oops, I already pushed with the wrong email!"&lt;br&gt;
I did this. I pushed a commit to my company repo, and it showed my personal Gmail and profile picture. Panic mode! 🚨&lt;/p&gt;

&lt;p&gt;But you can fix it without deleting the repo.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Fix your config first:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;git&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;config&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;user.email&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"work@company.com"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Amend the last commit: This command rewrites the last commit with your new config.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;git&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;commit&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;--amend&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;--reset-author&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;--no-edit&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Force Push: Since you changed history, you need to force the update.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;git&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;push&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;-f&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;origin&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;main&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And just like that, your commit history is clean!&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Setting this up takes about 10 minutes, but it saves you from endless "Permission Denied" errors and the embarrassment of mixing up identities. Once the SSH Agent service and Config file are set, everything just works in the background.&lt;/p&gt;

&lt;h1&gt;
  
  
  Happy Coding! 🚀
&lt;/h1&gt;

</description>
      <category>devops</category>
      <category>git</category>
      <category>productivity</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
