Associating a username with a repository

When working with a private repository, GitHub will force you to provide a username and password (or personal access token if two-step authentication has been configured) every time you want to do anything that affects the repository (e.g. clone, pull, push, fetch).

If you associate a specific username with the repository (from a user authorized to access the repository, duh) GitHub will then only need the password before letting you do what you need to.

You can do this when you first clone the repository:

 git clone https://[username]@github.com/[repository_username]/[project_name].git

Or after:

 git config remote.origin.url https://[username]@github.com/[repository_username]/[project_name].git

Making a habit of this has the added bonus of preventing you from encountering any unpleasant 403 Forbidden errors.

You could store your password this way too, but, seeing as it would be saved as plaintext in the .git directory I wouldn’t recommend it. Call me cynical.

If providing a password is still taking up too much of your time, you could generate an SSH key (precluding the need for either a username or password) or just use GitHub’s shiny new desktop client.