Cloning Git repositories with Git accounts on the same Windows computer

From the same Visual Studio Code on Windows, I want to be able to work with repositories from

This would more generally apply to any two accounts (Bitbucket, GitLab etc.)

Guide

This stackoverflow question is one I’ve referenced several times.

Email addresses

It’s worth remembering that Git requires a username and email address to be associated with each commit. Use git config to view, and then set these for command line Git operations

View


git config --global user.name
git config --global user.email

Set


git config --global user.name "Firstname Lastname"
git config --global user.email "email@example.com"

If you’re using GitHub, they have Emails setting where you can keep your personal email address private and effectively use a GitHub-generated one:

when performing web-based Git operations (e.g. edits and merges) and sending email on your behalf

They also call out the point:

If you want command line Git operations to use your private email you must set your email in Git

Note that if you already have a commit with a non-obfuscated email address, you might need to run git commit --amend --reset-author, wrapped in git rebase commands as described on GitHub

Software

  • Visual Studio Code
  • Git Credential Manager for Windows, as this includes:
    • Secure password storage in the Windows Credential Store.
    • Multi-factor authentication support for Azure DevOps.
    • Two-factor authentication support for GitHub.
    • Two-factor authentication support for Bitbucket.
    • Personal Access Token generation and usage support for Azure DevOps, GitHub, and Bitbucket.

The simplest answer might be this response


See also