DEV Community

keshav Sandhu
keshav Sandhu

Posted on

How to Use Multiple GitHub Accounts Without SSH on Windows (Using Windows Credentials Manager)

Managing multiple GitHub accounts on Windows can be tricky, especially when dealing with credentials. Here's a step-by-step guide to handle this efficiently using Windows Credential Manager and project-specific configurations.


Step 1: Remove Existing GitHub Credentials

Before starting, clear any saved GitHub credentials to avoid conflicts:

  1. Open Control PanelCredential Manager.
  2. Switch to the Windows Credentials tab.
  3. Look for entries like git:https://github.com and remove them.

This ensures a clean slate for adding new credentials.


Step 2: Configure Git Username and Password for a Specific Project

To associate a GitHub account with a specific project:

  1. Navigate to your project's .git folder (ensure hidden files are visible).
  2. Open the config file in a text editor.
  3. Add the following under the [remote "origin"] section:
   [remote "origin"]
       url = https://your-username:your-personal-access-token@github.com/your-repo-name.git
Enter fullscreen mode Exit fullscreen mode

Replace:

  • your-username with your GitHub username.
  • your-personal-access-token with your Personal Access Token (PAT).
  • your-repo-name with your repository's path.
  1. Save the file.

This stores credentials for that specific project and prevents Git from asking for authentication each time.


Step 3: Use Another GitHub Account in a Different Project

For other projects, simply clone or initialize the repository as usual. When you push or pull, Git will prompt you to log in via your browser.


Step 4: Switching Between Accounts

After setting up multiple accounts:

  • First Project: Credentials saved in the config file will be used automatically.
  • Other Projects: Git will prompt you to select or enter credentials. To avoid repeated prompts, repeat Step 2 for each project with the desired account.

Step 5: Removing Project-Specific Credentials

If you want to remove or update credentials for a project:

  1. Open the .git/config file.
  2. Remove or modify the url under [remote "origin"].

Step 6: Generating a Personal Access Token (PAT)

GitHub now requires a Personal Access Token instead of a password. Here’s how to generate one:

  1. Go to your GitHub ProfileSettings.
  2. Navigate to Developer SettingsPersonal Access TokensTokens (classic).
  3. Click Generate New Token and select the required scopes (e.g., repo, workflow).
  4. Copy the token and use it as the password in Step 2.

Final Notes

  • This method ensures smooth switching between multiple GitHub accounts without SSH.
  • Be cautious about storing credentials in the URL; only do so for non-sensitive projects.

Top comments (0)