Reverting Back to a Single GitHub Setup: Simplify Your SSH Configurations and Repo Management

Rahul Kumar
3 min readSep 1, 2024

--

Many developers manage multiple GitHub accounts on a single machine for personal and work projects, but this setup can become unnecessarily complex over time. If you’ve switched companies or no longer need multiple accounts, simplifying your configuration is a smart move.

In this guide, I’ll show you how I reverted to a single GitHub account setup by removing unused SSH keys, adjusting Git settings, and updating repository remote URLs — all with minimal disruption. Below is the old configuration I had and the steps I took to clean it up..

Previous SSH Config Setup:

For context, here’s what my SSH configuration looked like before the cleanup:

#office account
Host github.com-office
HostName github.com
User git
IdentityFile ~/.ssh/office

#personal account
Host github.com-personal
HostName github.com
User git
IdentityFile ~/.ssh/personal

This setup allowed me to work with two different GitHub accounts on the same machine. However, after switching companies, I wanted to revert to a single account setup with minimal changes to my existing repositories.

Step 1: Remove Unused SSH Configurations

The first step is to clean up your SSH config file by removing or adjusting the entries related to accounts you no longer need.

  • Open your SSH configuration file:
nano ~/.ssh/config
  • Remove or comment out the lines related to the account you no longer need, or modify the relevant entry to use the default github.com host:
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/personal

Step 2: Remove Unused SSH Keys

Next, you can remove the SSH keys that were associated with the old account:

  • To delete the keys:
rm ~/.ssh/office
rm ~/.ssh/office.pub
  • Alternatively, if you prefer to keep the keys as a backup, move them to a backup location:
mv ~/.ssh/office ~/.ssh/office_backup
mv ~/.ssh/office.pub ~/.ssh/office_backup.pub

Step 3: Set Global Git Configurations

If you haven’t already, make sure your global Git configurations are set correctly for the single account you’ll be using:

git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"

Step 4: Check and Update Remote URLs in Existing Repositories

Finally, you’ll need to check the remote URLs for your existing repositories to ensure they point to the correct GitHub account:

  • Check the remote URLs:
git remote -v
  • If the URL points to github.com, you're all set. If a repository uses a custom host like github.com-personal, you'll need to update the remote URL:
git remote set-url origin git@github.com:your-username/repository-name.git

This step ensures that your repositories use the default github.com host and connect to your personal GitHub account correctly.

Conclusion:

By following these steps, you can easily clean up your GitHub setup and revert to a single account configuration. This not only simplifies your SSH configuration but also reduces the chance of running into authentication issues in the future. With your repositories now connected to the correct account, you can focus on what matters most — your code.

Further Reading:

If you find yourself frequently updating Git remote URLs and want to automate the process, check out my guide on Creating a Custom Terminal Function to Set Git Remote URLs. It walks you through how to streamline this task with a simple command, saving time and reducing errors in your workflow.

--

--

Rahul Kumar
Rahul Kumar

Written by Rahul Kumar

I'm a Frontend Developer. I have a strong passion for UI effects, animations, and creating intuitive, dynamic user experiences.

No responses yet