<?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: Ishaan Mittal</title>
    <description>The latest articles on Forem by Ishaan Mittal (@ishaan-mittal).</description>
    <link>https://forem.com/ishaan-mittal</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%2F1358844%2F40114515-ea4b-4ead-bd8a-0c7c7ad17df0.jpg</url>
      <title>Forem: Ishaan Mittal</title>
      <link>https://forem.com/ishaan-mittal</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/ishaan-mittal"/>
    <language>en</language>
    <item>
      <title>How to Use Two GitHub Profiles on One Machine</title>
      <dc:creator>Ishaan Mittal</dc:creator>
      <pubDate>Mon, 23 Dec 2024 15:46:46 +0000</pubDate>
      <link>https://forem.com/ishaan-mittal/how-to-use-two-github-profiles-on-one-machine-43kn</link>
      <guid>https://forem.com/ishaan-mittal/how-to-use-two-github-profiles-on-one-machine-43kn</guid>
      <description>&lt;p&gt;Hey there! I'm going to show you how to use two GitHub profiles on one machine. This is useful if you have a personal and a work GitHub account and want to keep them separate. I faced this issue when I needed to have a separate GitHub account for all my company-related work. I wanted to keep my personal projects separate from my work projects, so I had to figure out how to use two GitHub profiles on one machine.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pre-requisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A GitHub account (two accounts if you want to follow along)&lt;/li&gt;
&lt;li&gt;Git installed on your machine&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Installing GitHub CLI
&lt;/h2&gt;

&lt;p&gt;GitHub CLI is a command-line tool that allows you to interact with GitHub from the terminal. You can install GitHub CLI by following the instructions on the &lt;a href="https://cli.github.com/" rel="noopener noreferrer"&gt;GitHub CLI website&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Authenticating your GitHub Accounts
&lt;/h2&gt;

&lt;p&gt;Once you have GitHub CLI installed, you can authenticate your GitHub accounts by running the following commands in your terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gh auth login
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command will prompt you to log in to your GitHub account using your web browser. Keep the browser having the desired account open to which you want to authenticate before running the command.&lt;/p&gt;

&lt;p&gt;After Logging in, confirm that you have logged in to both accounts by running the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gh auth status
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should be able to see your two authenticated accounts and the account that is currently active with &lt;code&gt;Active Account&lt;/code&gt; set to &lt;code&gt;true&lt;/code&gt; under that account.&lt;/p&gt;

&lt;p&gt;You can switch between active accounts by running the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gh auth switch
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The active account gives you access to the repositories associated with that account.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using Two GitHub Profiles
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;To have access to your desired account and its GitHub repositories, make that account your active account using GitHub CLI:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gh auth switch
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;To associate your commits with your desired GitHub account, set the user name and email for your account for that repository.:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git config user.name &lt;span class="s2"&gt;"Your Name"&lt;/span&gt;
git config user.email &lt;span class="s2"&gt;"personalEmail@gmail.com"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you want to use any one of your accounts for most of your repositories, you can use the global option &lt;code&gt;--global&lt;/code&gt; to set the user name and email for all repositories on your machine.&lt;/p&gt;

&lt;p&gt;Refer to the &lt;a href="https://docs.github.com/en/account-and-profile/setting-up-and-managing-your-personal-account-on-github/managing-email-preferences/setting-your-commit-email-address" rel="noopener noreferrer"&gt;Git documentation&lt;/a&gt; for more on who your commits are associated with your GitHub account.&lt;/p&gt;

&lt;p&gt;Let me know if you have any questions. I hope this helps you in managing your personal and work GitHub accounts on one machine. Happy coding!&lt;/p&gt;

</description>
      <category>github</category>
    </item>
  </channel>
</rss>
