Published on

Using a different GitHub account for a repository

Authors

How to use a different GitHub account for a repository?

  1. Configure your Git Username and Email globally: If you haven't already done so, you can configure your global Git settings with the username and email of the account you want to use. Open a terminal and use the following commands, replacing "primary_username" and "primary_email@example.com" with your GitHub account details:

    git config --global user.name "primary_username"
    git config --global user.email "primary_email@example.com"
    
  2. Clone the Repository: Clone the repository you want to contribute to using the following command:

    git clone <repository_URL>
    
  3. Change Directory to the cloned repository: Navigate into the directory of the cloned repository using the cd command:

    cd <repository_name>
    
  4. Configure User locally for the Repository: Inside the repository directory, configure your local Git settings with the username and email associated with the alternate GitHub account:

     git config user.name "secondary_username"
     git config user.email "secondary_email@example.com"