Загрузка...

How to Switch GitHub Accounts in Visual Studio Code Terminal

Struggling to switch GitHub accounts in Visual Studio Code? Discover the effective steps to ensure your commits are credited correctly to your primary account.
---
This video is based on the question https://stackoverflow.com/q/65588152/ asked by the user 'BigProgrammer_67' ( https://stackoverflow.com/u/10836143/ ) and on the answer https://stackoverflow.com/a/65588764/ provided by the user 'VonC' ( https://stackoverflow.com/u/6309/ ) at 'Stack Overflow' website. Thanks to these great users and Stackexchange community for their contributions.

Visit these links for original content and any more details, such as alternate solutions, latest updates/developments on topic, comments, revision history etc. For example, the original title of the Question was: I can't switch github accounts in visual studio code terminal

Also, Content (except music) licensed under CC BY-SA https://meta.stackexchange.com/help/licensing
The original Question post is licensed under the 'CC BY-SA 4.0' ( https://creativecommons.org/licenses/by-sa/4.0/ ) license, and the original Answer post is licensed under the 'CC BY-SA 4.0' ( https://creativecommons.org/licenses/by-sa/4.0/ ) license.

If anything seems off to you, please feel free to write me at vlogize [AT] gmail [DOT] com.
---
How to Switch GitHub Accounts in Visual Studio Code Terminal

Switching GitHub accounts in Visual Studio Code (VS Code) can be a frustrating experience, especially if it looks like your commits are being credited to an account you no longer intend to use. This issue is not unique, and many developers encounter it. Fortunately, there are clear steps you can follow to resolve the problem and ensure your commits are attributed to the correct account.

In this guide, we’ll dive into the solutions for effectively switching GitHub accounts in your VS Code terminal, explaining both authentication and authorship in Git, and how to correctly configure your repository settings.

The Problem

You've recently logged out of a previous GitHub account and logged into your main account. However, when pushing changes to your repository, you notice that:

The commits are still being associated with the previous account instead of your main account.

Removing credentials from the control panel and restarting your PC doesn't seem to fix the issue.

When attempting to push changes, a credentials window continues to pop up, and even after logging into your main account, the commits do not reflect the changes you expect.

This situation arises because of two main aspects within Git:

Authentication - This refers to the account you log into through the popup credentials window.

Authorship - This is the name and email you’ve set up in your Git configuration, which directly relates to how commits are attributed.

Understanding Authentication and Authorship in Git

To effectively switch accounts in Git, it's crucial to differentiate between authentication and authorship:

Authentication is tied to the username and password you enter in the credentials popup. This determines which account you are logged in as when interacting with remote repositories.

Authorship is defined by the user name and email that Git uses for commit records, which are set in your local repository configuration.

How to Check Your Configuration

To identify the current author configuration for your repository, use the following commands in your terminal:

[[See Video to Reveal this Text or Code Snippet]]

These commands return the username and email associated with your commits. If this information does not match your desired main account, you will need to update it.

Steps to Switch GitHub Accounts

Here’s how to properly configure your Git user settings to resolve the issue of commits being credited to the wrong account:

1. Clear Old Credentials

Ensure that the old credentials have been fully removed:

Open the Control Panel on Windows.

Navigate to User Accounts Credential Manager.

Under Windows Credentials, locate any GitHub-related entries and remove them.

2. Update Git Configuration for Authorship

As mentioned earlier, the configuration tying your commits to a specific email and name must match your main account:

[[See Video to Reveal this Text or Code Snippet]]

This command will set the username and email for your local repository.

3. Check Local Repository Configuration

Ensure that your updates have been applied specifically to the local repository you are working in. You can find the Git configuration file located at:

[[See Video to Reveal this Text or Code Snippet]]

Make sure it reflects the correct account details.

4. Push Changes to the Remote Repository

After updating your configurations, attempt to push your changes again:

[[See Video to Reveal this Text or Code Snippet]]

When prompted for credentials, enter your main account information.

5. Verify Commits

After pushing your changes, double-check the commit history to confirm that your commits are now attributed correctly to y

Видео How to Switch GitHub Accounts in Visual Studio Code Terminal канала vlogize
Страницу в закладки Мои закладки
Все заметки Новая заметка Страницу в заметки

На информационно-развлекательном портале SALDA.WS применяются cookie-файлы. Нажимая кнопку Принять, вы подтверждаете свое согласие на их использование.

Об использовании CookiesПринять