Change GitLab Account on your local Git configuration on Windows

The amazing Gitlab

Recently, I created a new GitLab account and wanted to switch to it on my local machine. When pushing to a remote repository, the credentials from the first account are still being used. Typically, you need to remove the old user credentials and then authorize the new account. Here's how to do that on Windows.

1. Remove Stored Credentials

If you've been using HTTPS for authentication, your credentials might be stored in the Windows Credential Manager. Removing these old credentials is the first step to ensure that your local machine asks for the new ones.

Using Windows Credential Manager
  • Open Credential Manager:
    Press Win + S, type "Credential Manager" and open it.
  • Find GitLab Credentials:
    Navigate to the "Windows Credentials" tab and look for entries related to GitLab, which are likely named something like git:https://gitlab.com. Remove these entries to delete the stored credentials.
  • Remove these credentials

2. Update Git User Configuration

Once you've removed the old credentials, you need to update the Git user configuration to reflect your new GitLab account. This step involves setting the correct username and email associated with your new account.

For a Specific Repository

If you only want to update the user information for a specific repository, navigate to the repository folder and set the new user details:

cd /path/to/your/repository
git config user.name "YourNewUserName"
git config user.email "your.new.email@example.com"

Now you can push to the remote repository in GitLab using the new account. Congrats!

Globally (For All Repositories)

To update the user information for all repositories on your machine, use the global configuration:

git config --global user.name "YourNewUserName"
git config --global user.email "
your.new.email@example.com"

I've found GitLab to be an excellent platform, especially when it comes to hosting private repositories. Unlike GitHub, which offers limited private repositories for free, GitLab has no such restriction. This makes it an ideal choice for developing proprietary applications or any project that you prefer to keep private. Whether you're just starting out or managing a full-scale project, GitLab's features and flexibility make it a valuable tool for any developer.

Popular posts from this blog

ERROR 1348 Column Password Is Not Updatable When Updating MySQL Root Password

How To Create Spring Boot Project Using Netbeans

Spring Kafka - How to use ReplyingKafkaTemplate send and reply synchronously