---
# System prepended metadata

title: Query 180

---

Cloning a private GitHub repository using Visual Studio Code (VSCode) involves some additional steps compared to cloning a public repository. You need to set up access tokens, manage credentials, and ensure secure access to private project code. Here's how to do it [1][2]:
1. Create a Personal Access Token (PAT): If you haven't already, create a GitHub Personal Access Token (PAT). You can do this in your GitHub account settings. Make sure to grant the PAT the necessary permissions (usually `repo` or `repo, read:packages` for private repositories).
2. Store the PAT Securely: Store your PAT securely, either as an environment variable or in a credential manager. Avoid hardcoding it in your code or configuration files.
3. Set Up Git Credentials: You'll need to configure Git to use your PAT for authentication. There are different ways to do this:
    * Credential Manager: On Windows, you can use the Windows Credential Manager to store your PAT.
    * SSH Keys: You can use SSH keys for authentication. In this case, ensure your SSH key is associated with your GitHub account.
4. VSCode Configuration: Configure VSCode to use your Git credentials. This is especially important if you're using VSCode's integrated terminal. Open VSCode and navigate to `File" > "Preferences" > "Settings`, and search for `git authentication`.
5. Cloning the Private Repository:
    * Open VSCode and use the "Source Control" tab (Ctrl+Shift+G) to clone the private repository.
    * Enter the repository URL in the following format: `https://USERNAME:TOKEN@github.com/USERNAME/REPO.git`, replacing USERNAME with your GitHub username, TOKEN with your PAT, and REPO with the repository name.
    * For example:
        ```
            https://yourusername:yourtoken@github.com/yourusername/your-repo.git
        ```
        Click the `Clone` button. VSCode should use your PAT for authentication
6. Visual Studio Code Git Integration: VSCode has built-in Git integration, and when you attempt to clone a private repository, it may prompt you for your GitHub credentials. You can choose to remember these credentials.
7. Access Control: Ensure that your GitHub account and repository settings have the appropriate access controls. You can grant access to specific users or teams, and make sure your PAT has the required permissions.

By following these steps, you can securely clone and work with private GitHub repositories in VSCode. It's important to store your PAT securely and configure Git and VSCode to use it for authentication, so you can access your private project code without exposing sensitive information.