DEV Community

Raihanul Islam Sharif
Raihanul Islam Sharif

Posted on

Remove Older Github Account From Your PC

1.Remove Global Configurations:
Open your command line or terminal and run the following commands to remove the global Git configurations associated with your old GitHub account:

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

2.Remove Stored Credentials:
Depending on your operating system, Git might have cached your GitHub credentials. You need to clear this cache so that you can enter new credentials when pushing code. Use the following commands:
For Windows:
git credential-manager-core erase

3. Update Repository URL:
If you had repositories cloned using the old GitHub account, you might want to update the remote URL to the new GitHub account's repositories. Navigate to each repository directory and update the remote URL using the following command:

git remote set-url origin https://github.com/your-new-username/your-repo-name.git

Replace "your-new-username" with your new GitHub username and "your-repo-name" with the name of the repository.

4 Push Changes:
Once you've removed the old GitHub account's configurations and credentials, and updated the repository URLs if needed, you should be able to push code using your new GitHub account:

git push -u origin main

Git will prompt you to enter your new GitHub account's credentials, and the changes will be pushed to the repository associated with your new account.

Following these steps will ensure that your local machine is set up to use only your new GitHub account for pushing code and interacting with repositories.

Top comments (0)