Skip to content

Commit

Permalink
docs: add TL;DR section on how to update remote URL
Browse files Browse the repository at this point in the history
  • Loading branch information
mjcheetham committed May 22, 2023
1 parent 2d3288d commit c23e5e9
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions docs/multiple-users.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ If you work with multiple different identities on a single Git hosting service,
you may be wondering if Git Credential Manager (GCM) supports this workflow. The
answer is yes, with a bit of complexity due to how it interoperates with Git.

---

**Prompted to select an account?**

Read the [**TL;DR** section][tldr] below for a quick summary of how to make GCM
remember which account to use for which repository.

---

## Foundations: Git and Git hosts

Git itself doesn't have a single, strong concept of "user". There's the
Expand Down Expand Up @@ -86,4 +95,28 @@ You can use the `github [list | login | logout]` commands to manage your GitHub
accounts. These commands are documented in the [command-line usage][cli-usage]
or by running `git-credential-manager github --help`.

## TL;DR: Tell GCM to remember which account to use

The easiest way to have GCM remember which account to use for which repository
is to include the account name in the remote URL. If you're using HTTPS remotes,
you can include the account name in the URL by inserting it before the `@` sign
in the domain name.

For example, if you want to always use the `alice` account for the `mona/test`
GitHub repository, you can clone it using the `alice` account by running:

```shell
git clone https://alice@github.com/mona/test
```

To update an existing clone, you can run `git remote set-url` to update the URL:

```shell
git remote set-url origin https://alice@github.com/mona/test
```

If your account name includes an `@` then remember to escape this character
using `%40`: `https://alice%40contoso.com@example.com/test`.

[tldr]: #tldr-tell-gcm-to-remember-which-account-to-use
[cli-usage]: usage.md

0 comments on commit c23e5e9

Please sign in to comment.